title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
overflow hidden on a Paragraph in Reportlab
39,627,803
<p>I have a <code>Table</code> with 2 cells, inside of each one there is a <code>Paragraph</code></p> <pre><code>from reportlab.platypus import Paragraph, Table, TableStyle from reportlab.lib.styles import ParagraphStyle from reportlab.lib.units import cm table_style_footer = TableStyle( [ ...
1
2016-09-21T23:03:36Z
39,641,038
<p>Reportlab doesn't seem to have a native support for hiding overflow, but we can achieve it by utilizing the <code>breakLines</code> function of a <code>Paragraph</code>. The <code>breakLines</code> functions returns an object that contains all the lines of the paragraph given a certain width, thus we can also use it...
2
2016-09-22T13:53:39Z
[ "python", "python-3.x", "reportlab", "platypus" ]
Finding the smallest common denominator
39,627,822
<p>I have the following problem. I have a arrays of <code>L</code> binary entries.(<code>L</code> is usually between 2 and 8 if it is of interest.) All possible combinations do exist. So there are <code>2^L</code> arrays in one realisation. Now each combination will get randomly a fitness value assigned. The fitness va...
2
2016-09-21T23:05:54Z
39,628,120
<p>Assuming that this <code>fitness value</code> may depend of the value of each bit in your binary entry, and that you're searching the rules that can sum up your truth table (I'm not sure I understood your question very well about this point), You could use something like a <a href="https://en.wikipedia.org/wiki/Karn...
1
2016-09-21T23:44:17Z
[ "python" ]
Finding the smallest common denominator
39,627,822
<p>I have the following problem. I have a arrays of <code>L</code> binary entries.(<code>L</code> is usually between 2 and 8 if it is of interest.) All possible combinations do exist. So there are <code>2^L</code> arrays in one realisation. Now each combination will get randomly a fitness value assigned. The fitness va...
2
2016-09-21T23:05:54Z
39,629,480
<p>As already mentioned, this is a combinational logic minimization problem.</p> <p>The algorithm typically used is Quine-Mccluskey and somebody has already asked for and posted a Python implementation:</p> <p><a href="http://stackoverflow.com/questions/7537125/quine-mccluskey-algorithm-in-python">Quine-McCluskey alg...
1
2016-09-22T02:49:50Z
[ "python" ]
Invalidate Flask session?
39,627,827
<p>I'm testing JSON based login/logout functionality with httpie (<a href="https://github.com/jkbrzt/httpie#sessions" rel="nofollow">https://github.com/jkbrzt/httpie#sessions</a>). The problem I have is that once I login no matter how many times I "logout" I can not clean up the session. On the logout I can see clearly...
0
2016-09-21T23:06:39Z
39,649,464
<p>Solved it .... didn't know that by default Flask uses client-side sessions !?!!? whaaat !!</p> <p>Once you install Flask-Session instead everything is fine ! <a href="https://pythonhosted.org/Flask-Session/" rel="nofollow">https://pythonhosted.org/Flask-Session/</a></p>
0
2016-09-22T21:53:32Z
[ "python", "json", "session", "flask" ]
Python - Ciphertext length must be equal to key size - different string length after passing it to server
39,627,844
<p>I have a problem with decoding the encrypted message after passing it from client to the server. I am using <a href="https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/" rel="nofollow">Cryptography</a>. I am encoding the message on the client side using the script below:</p> <pre><code>encMessage = ...
1
2016-09-21T23:09:35Z
39,648,542
<p>Your encrypted message is a binary blob of data, and you seem to treat it as string in javascript, but javascript strings are not made for binary data, and when the transport format is json it gets even more complicated.</p> <p>The standard approach would be to base64 encode the encrypted message before sending and...
1
2016-09-22T20:42:43Z
[ "python", "string", "cryptography" ]
Number of rows in numpy array
39,627,852
<p>I know that numpy array has a method called shape that returns [No.of rows, No.of columns], and shape[0] gives you the number of rows, shape[1] gives you the number of columns. </p> <pre><code>a = numpy.array([[1,2,3,4], [2,3,4,5]]) a.shape &gt;&gt; [2,4] a.shape[0] &gt;&gt; 2 a.shape[1] &gt;&gt; 4 </code></pre> <...
1
2016-09-21T23:10:08Z
39,627,884
<p>The concept of <em>rows</em> and <em>columns</em> applies when you have a 2D array. However, the array <code>numpy.array([1,2,3,4])</code> is a 1D array and so has only one dimension, therefore <code>shape</code> rightly returns a single valued iterable. </p> <p>For a 2D version of the same array, consider the foll...
4
2016-09-21T23:13:40Z
[ "python", "arrays", "numpy" ]
Number of rows in numpy array
39,627,852
<p>I know that numpy array has a method called shape that returns [No.of rows, No.of columns], and shape[0] gives you the number of rows, shape[1] gives you the number of columns. </p> <pre><code>a = numpy.array([[1,2,3,4], [2,3,4,5]]) a.shape &gt;&gt; [2,4] a.shape[0] &gt;&gt; 2 a.shape[1] &gt;&gt; 4 </code></pre> <...
1
2016-09-21T23:10:08Z
39,627,945
<p>Rather then converting this to a 2d array, which may not be an option every time - one could either check the <code>len()</code> of the tuple returned by shape or just check for an index error as such:</p> <pre><code>import numpy a = numpy.array([1,2,3,4]) print(a.shape) # (4,) print(a.shape[0]) try: print(a.s...
1
2016-09-21T23:21:01Z
[ "python", "arrays", "numpy" ]
How to use MongoDB with Django Framework and Python3
39,627,869
<p>I am a newbie to python,django, and mongoDB world. I've setup Django project (Virtualenv, Python3, Django==1.10.1 MongoDB) and installed some basic package requirements: </p> <pre><code>Django==1.10.1 django-mongodb-engine==0.6.0 djangotoolbox==1.8.0 mongoengine==0.9.0 pymongo==3.3.0 </code></pre> <p>but when I tr...
1
2016-09-21T23:11:55Z
39,633,607
<p>From the docs <a href="https://django-mongodb-engine.readthedocs.io/en/latest/topics/setup.html#configuration" rel="nofollow">django-mongodb-engine</a></p> <pre><code>DATABASES = { 'default' : { 'ENGINE' : 'django_mongodb_engine', 'NAME' : 'my_database' } } </code></pre>
1
2016-09-22T08:10:07Z
[ "python", "django", "mongodb", "python-3.x", "pymongo" ]
Desk Price Calculation in Python
39,627,886
<p>I have a little exercise I need to do in Python that's called "Desk Price Calculation". There need to be 4 functions which are used in the program. </p> <p>My main problem is using the output of a function in another function.</p> <pre><code>def get_drawers(): drawers = int(input('How many goddamn drawers woul...
-2
2016-09-21T23:13:48Z
39,627,948
<p>I guess you get an error like this (that should have been added to your question by the way) :</p> <pre><code>Traceback (most recent call last): File "test.py", line 42, in &lt;module&gt; display_price() TypeError: display_price() missing 3 required positional arguments: 'price', 'wood', and 'drawer_count' </...
0
2016-09-21T23:21:25Z
[ "python", "python-3.x", "price" ]
Desk Price Calculation in Python
39,627,886
<p>I have a little exercise I need to do in Python that's called "Desk Price Calculation". There need to be 4 functions which are used in the program. </p> <p>My main problem is using the output of a function in another function.</p> <pre><code>def get_drawers(): drawers = int(input('How many goddamn drawers woul...
-2
2016-09-21T23:13:48Z
39,627,971
<p>It would appear that you wanted to pass in some parameters to your method. </p> <p>If that is the case, you need to move the "calculate" and "get" functions.</p> <p>And, no need to re-prompt for input - you already have parameters</p> <pre><code>def calculate_price(wood_type, drawers): # wood_type = get_wood_...
0
2016-09-21T23:23:53Z
[ "python", "python-3.x", "price" ]
How do I get the username of the current user in a Flask app on an IIS server using Windows Authentication?
39,627,947
<p>I have a Flask app (Python 2.7) running on an IIS server in Windows 10. The server is configured to use Windows Authentication. I am using an HttpPlatformHandler in order to execute the Python code. </p> <p>I have verified that the authentication is working and am able to see the Kerberos "Negotiate" auth header. ...
0
2016-09-21T23:21:17Z
39,648,839
<p>It turns out that the answer on <a href="http://stackoverflow.com/questions/33347412/rails-app-remote-user-attribute-in-iis-8-5-with-windows-authentication">this post</a> works for my configuration as well. I simply downloaded ISAPI_Rewrite 3, copy and pasted the text into httpd.conf, and was able to access the name...
0
2016-09-22T21:04:21Z
[ "python", "iis", "flask", "windows-authentication" ]
Why does my Python XML parser break after the first file?
39,627,960
<p>I am working on a Python (3) XML parser that should extract the text content of specific nodes from every xml file within a folder. Then, the script should write the collected data into a tab-separated text file. So far, all the functions seem to be working. The script returns all the information that I want from th...
1
2016-09-21T23:22:24Z
39,628,092
<p>You are overwriting your function calls with the values they returned. changing the function names should fix it.</p> <pre><code>import xml.etree.ElementTree as ET import re import glob import csv import sys content_file = open('WWP Project/WWP_texts.txt','wt') quotes_file = open('WWP Project/WWP_quotes.txt', 'wt...
1
2016-09-21T23:39:58Z
[ "python", "for-loop", "xml-parsing" ]
from openpyxl.styles import Style, Font ImportError: cannot import name Style
39,628,005
<p>While running a python code, I am facing the following error :</p> <pre><code>sbassi-mbpro:FacebookEventScraper-master sbassi$ python facebook_event_scraper.py Traceback (most recent call last): File "facebook_event_scraper.py", line 13, in &lt;module&gt; from openpyxl.styles import Style, Font ImportError: ...
0
2016-09-21T23:27:16Z
39,628,053
<p>Looking at the <a href="https://bitbucket.org/openpyxl/openpyxl/src/a4373fb5b471/openpyxl/styles/?at=default" rel="nofollow">source code</a> for openpyxl.styles, the <a href="https://bitbucket.org/openpyxl/openpyxl/src/a4373fb5b471f8dd6000b06e675cf37fe6a0ccad/openpyxl/styles/__init__.py?at=default&amp;fileviewer=fil...
1
2016-09-21T23:32:56Z
[ "python", "openpyxl" ]
inserting python variable data into sqlite table not saving
39,628,043
<p>I'm querying a json on a website for data, then saving that data into a variable so I can put it into a sqlite table. I'm 2 out of 3 for what I'm trying to do, but the sqlite side is just mystifying. I'm able to request the data, from there I can verify that the variable has data when I test it with a print, but all...
0
2016-09-21T23:31:39Z
39,628,146
<p>Your table likely isn't created because you haven't committed yet, and your sql fails before it commits. It should work when you fix your 2nd sql statement.</p> <p>You're not inserting the variables you've created into the table. You need to use parameters. There are <a href="https://docs.python.org/2/library/sq...
0
2016-09-21T23:47:15Z
[ "python", "sqlite", "zendesk" ]
Items are not adding in correctly in QTableWidget in Maya
39,628,044
<p>I am trying to create a table, where it has 2 columns and several rows. Column1 will be listing all the available mesh/geos in the scene while Column2 will be in the form of combo box per cell where it contains several options - depending on the mesh/geos from Column1, it will lists different shader options in the c...
0
2016-09-21T23:31:46Z
39,630,491
<p>In your <code>setTable()</code> method, you are looping through the geometries, then you are looping through the rows. Since each geometry represents a row you only really need to loop through them and remove the other loop.</p> <p>Modifying it like so fixes the output:</p> <pre><code>def setTable(self): # Add...
1
2016-09-22T04:50:22Z
[ "python", "pyqt", "maya" ]
read number of users from OS using python
39,628,113
<p>I am writing a nagios plugin that would exit based on number of users that are logged into my instance.</p> <pre><code>import argparse import subprocess import os import commands import sys if __name__ == '__main__': parser = argparse.ArgumentParser(description='checks number of logged in users') p...
0
2016-09-21T23:43:25Z
39,628,156
<p>To convert string to integer use function int(). For instance <code>res_integer = int(res)</code></p>
1
2016-09-21T23:48:25Z
[ "python", "shell", "python-os" ]
Is there a way to set a tag on an EC2 instance while creating it?
39,628,128
<p>Is that a way to create an EC2 instance with tags(I mean, adding tag as parameter when creating instance)</p> <p>I can't find this function in boto APIs. According to the document, we can only add tags after creating. </p> <p>However, when creating on the browser, we can configure the tags when creating. So can w...
0
2016-09-21T23:44:44Z
39,649,819
<p>At the time of writing, there is no way to do this in a single operation.</p>
0
2016-09-22T22:25:23Z
[ "python", "amazon-web-services", "amazon-ec2", "boto" ]
Giving input and output files for batch processing?
39,628,131
<p>I have more than 100 .txt files in a directory, that I want to run the same python script for each one of the files. Right now I have to type a similar command over 100 times because there is a slight variation for each command because the input and output file names are different. I was wondering if this could done...
0
2016-09-21T23:44:50Z
39,628,715
<p>I couldn't test this because I don't have the input files nor do I have all the third party modules installed that you do. However it should be close to what you should do, as I was trying to explain in the comments.</p> <pre><code>import glob import numpy as np import os import pandas as pd import sys def process...
0
2016-09-22T01:05:16Z
[ "python", "batch-processing" ]
Selenium Webdriver Python - implicit wait is not clear to me
39,628,191
<p>Other people have asked this question and there are some answers but they do not clarify one moment. Implicit wait will wait for a specified amount of time if element is not found right away and then will run an error after waiting for the specified amount of time. Does it mean that implicit wait checks for the elem...
0
2016-09-21T23:54:26Z
39,629,897
<p>In case of implicit wait driver waits till elements appears in DOM but at the same time it does not guarantee that elements are usable. Elements might not be enabled to be used ( like button click ) or elements might not have shape defined at that time. </p> <p>We are not interested with all the elements on the pag...
0
2016-09-22T03:44:48Z
[ "python", "selenium", "selenium-webdriver" ]
Selenium Webdriver Python - implicit wait is not clear to me
39,628,191
<p>Other people have asked this question and there are some answers but they do not clarify one moment. Implicit wait will wait for a specified amount of time if element is not found right away and then will run an error after waiting for the specified amount of time. Does it mean that implicit wait checks for the elem...
0
2016-09-21T23:54:26Z
39,630,409
<p><strong>Implicit Wait</strong> is internal to selenium. You set it once while initializing. Then every time web driver tries to look for a element it will look for that elmemt continiously (with some polling) presence till 'implicit wait' timer expires. If the element is found then it resumes execution otherwise thr...
0
2016-09-22T04:42:14Z
[ "python", "selenium", "selenium-webdriver" ]
Histograms in Pandas
39,628,242
<p>Relatively new to python and pandas. I have a dataframe: <code>df</code> with say 2 columns (say, <code>0</code> and <code>1</code>) and n rows. I'd like to plot the histograms of the two time series data represented in the two columns. I also need access to the exact counts in the histogram for each bin for later m...
0
2016-09-22T00:02:59Z
39,630,751
<p>I would directly use Pyplot's built in <a href="http://matplotlib.org/1.2.1/examples/pylab_examples/histogram_demo.html" rel="nofollow">histogram</a> function:</p> <pre><code>b_counts, b_bins, _ = plt.hist(df[0], bins = 10) a_counts, a_bins, _ = plt.hist(df[1], bins = 10) </code></pre> <hr> <p>As per the document...
1
2016-09-22T05:14:57Z
[ "python", "pandas", "numpy", "histogram", "bins" ]
How to save a value to be used after app.exec() exits in python?
39,628,267
<p>I would like to save/store mouse event values that were created in app.exec() as it was running. I would like to use the following code that I got from a post that I am having trouble finding now.(Will update with link to post where this code came from, once I find it.)</p> <pre><code>import sys from PyQt4 import Q...
0
2016-09-22T00:05:06Z
39,641,383
<p><code>app.exec_()</code> is not doing anything magical, it simply starts the event loop that handles all the GUI events. Your main function will block here until the GUI is shut down and the event loop exits. At this point the objects you have created are still in scope, that is, they have not been garbage collected...
0
2016-09-22T14:08:33Z
[ "python", "qt", "user-interface", "pyqt" ]
Why does the swapping work one way but not the other?
39,628,275
<p>For this <a href="https://leetcode.com/problems/first-missing-positive/" rel="nofollow">question</a> on leetcode, I attempted to solve with Python 2.7 with the code at the bottom of the post. However, for an input of <code>[2,1]</code>, the function will loop forever. But, if I change the line doing the swap, and sw...
1
2016-09-22T00:06:01Z
39,628,302
<p>The use of <strong>nums[i]-1</strong> as a subscript for <strong>nums</strong> introduces an extra evaluation that isn't in the order you want. Run a simple test, such as on the list [1, 2, 3, 4, 5, 6, 7] with just a few of these statements, and you'll see the result.</p> <p>If you handle just one intermediate ope...
1
2016-09-22T00:08:52Z
[ "python", "python-2.7" ]
Drawing a rectangle representing a value in python?
39,628,294
<p>How do I plot a rectangle with color representing a value like this picture in python? <a href="http://i.stack.imgur.com/OLvkW.png" rel="nofollow"><img src="http://i.stack.imgur.com/OLvkW.png" alt="enter image description here"></a> </p> <p>I have showed a rectangle but still trying to display values in the rectan...
0
2016-09-22T00:07:58Z
39,628,391
<p>You could, for example, use the text function from matplotlib library.</p> <p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.text" rel="nofollow">http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.text</a></p> <p>You can also find another solution in a similar post here:</p> <p><a h...
0
2016-09-22T00:21:19Z
[ "python", "matplotlib" ]
Print values in Python debugger
39,628,298
<p>In my Python code, I have this call inside a bounded method:</p> <pre><code>instances = instance_objects.InstanceList().get_by_host(ctxt, self.host) </code></pre> <p>When I debug with the Python debugger (pdb) and I issue <code>p instances</code> i get this output:</p> <pre><code>InstanceList(objects=[Instance(bd...
2
2016-09-22T00:08:24Z
39,641,562
<p>Try</p> <pre><code>p instances.objects[0].vcpus </code></pre>
1
2016-09-22T14:16:52Z
[ "python", "python-2.7", "pdb" ]
Run paho mqtt client loop_forever
39,628,305
<p>I am trying to run the following code on loop continuously. But the following code only runs once and takes only one message entry. </p> <p>What i a trying to do inside the on_message function is run a cron task using python apscheduler. </p> <pre><code>def on_message(mqttc, obj, msg): global val v...
1
2016-09-22T00:09:25Z
39,845,778
<p>a few issues.</p> <p>you have not detailed which version of python, apscheduler, mqtt and you have omitted your imports and some useful functions for troubleshooting like on_connect</p> <p>so testing this on python3 and apscheduler3.2 i think that you;</p> <ol> <li>you are using BlockingScheduler instead of Backg...
0
2016-10-04T06:44:25Z
[ "python", "apscheduler" ]
Optimizing a way to find all permutations of a string
39,628,308
<p>I solved a puzzle but need to optimize my solution. The puzzle says that I am to take a string <em>S</em>, find all permutations of its characters, sort my results, and then return the one-based index of where <em>S</em> appears in that list.</p> <p>For example, the string 'bac' appears in the 3rd position in the ...
1
2016-09-22T00:09:48Z
39,628,764
<p>Your bottleneck resides in the fact that the number of permutations of a list of N items is N! (N factorial). This number grows very fast as the input increases.</p> <p>The first optimisation you can do is that you do not have to store all the permutations. Here is a recursive solution that produces all the permu...
1
2016-09-22T01:13:05Z
[ "python", "optimization" ]
Optimizing a way to find all permutations of a string
39,628,308
<p>I solved a puzzle but need to optimize my solution. The puzzle says that I am to take a string <em>S</em>, find all permutations of its characters, sort my results, and then return the one-based index of where <em>S</em> appears in that list.</p> <p>For example, the string 'bac' appears in the 3rd position in the ...
1
2016-09-22T00:09:48Z
39,628,894
<p>I believe the answer is to not produce all the permutations nor sort them. Let's keep it simple and see how it compares performance-wise:</p> <pre><code>import itertools def listPosition(string): seen = set() target = tuple(string) count = 1; for permutation in itertools.permutations(sorted(str...
2
2016-09-22T01:31:12Z
[ "python", "optimization" ]
Optimizing a way to find all permutations of a string
39,628,308
<p>I solved a puzzle but need to optimize my solution. The puzzle says that I am to take a string <em>S</em>, find all permutations of its characters, sort my results, and then return the one-based index of where <em>S</em> appears in that list.</p> <p>For example, the string 'bac' appears in the 3rd position in the ...
1
2016-09-22T00:09:48Z
39,629,213
<p>Providing my own answer under the assumption that a good way to optimize code is to not use it in the first place. Since I strongly emphasized identifying ways to speed up the code I posted, I'm upvoting everyone else for having made improvements in that light.</p> <p>@Evert posted the following comment:</p> <bloc...
2
2016-09-22T02:17:38Z
[ "python", "optimization" ]
Parsing an irregularly spaced text file in Python pandas
39,628,453
<p>I have a text file that looks like :</p> <pre><code>Date Fruit-type Color count aug-6 apple green 4 aug-7 pear brown 5 aug-3 peach yellow 10 aug-29 orange orange 34 </code></pre> <p>I would like to parse it to remove the irregular spaces into a nicel...
1
2016-09-22T00:29:38Z
39,628,581
<p>If you can use command line tools, you can run this <code>awk</code> command to turn it from space delimited to comma delimited.</p> <pre><code>awk '{for (i=1; i&lt;NF; i++){printf "%s,", $i} print $NF}' data.txt </code></pre> <p>Otherwise, pandas can import space delimited files easily.</p> <pre><code>import pan...
5
2016-09-22T00:47:57Z
[ "python", "pandas" ]
Parsing an irregularly spaced text file in Python pandas
39,628,453
<p>I have a text file that looks like :</p> <pre><code>Date Fruit-type Color count aug-6 apple green 4 aug-7 pear brown 5 aug-3 peach yellow 10 aug-29 orange orange 34 </code></pre> <p>I would like to parse it to remove the irregular spaces into a nicel...
1
2016-09-22T00:29:38Z
39,640,255
<pre><code>gawk '{gsub(/[[:blank:]]+/, ",")}1' file Date,Fruit-type,Color,count aug-6,apple,green,4 aug-7,pear,brown,5 aug-3,peach,yellow,10 aug-29,orange,orange,34 </code></pre>
0
2016-09-22T13:21:08Z
[ "python", "pandas" ]
Zen of Python: Errors should never pass silently. Why does zip work the way it does?
39,628,456
<p>I use python's function zip a lot in my code (mostly to create dicts like below) </p> <pre><code>dict(zip(list_a, list_b)) </code></pre> <p>I find it really useful, but sometimes it frustrates me because I end up with a situation where list_a is a different length to list_b. zip just goes ahead and zips together ...
6
2016-09-22T00:30:01Z
39,628,556
<p>In my experience, the only reason that you would ever have two lists that happen to have the same length is because they were both constructed from the same source, e.g. they are <code>map</code>s of the same underlying source, they are constructed inside the same loop, etc. In these cases, rather than creating them...
0
2016-09-22T00:44:10Z
[ "python" ]
Zen of Python: Errors should never pass silently. Why does zip work the way it does?
39,628,456
<p>I use python's function zip a lot in my code (mostly to create dicts like below) </p> <pre><code>dict(zip(list_a, list_b)) </code></pre> <p>I find it really useful, but sometimes it frustrates me because I end up with a situation where list_a is a different length to list_b. zip just goes ahead and zips together ...
6
2016-09-22T00:30:01Z
39,628,603
<h2>Reason 1: Historical Reason</h2> <p><code>zip</code> allows unequal-length arguments because it was meant to improve upon <code>map</code> by <em>allowing</em> unequal-length arguments. This behavior is the reason <code>zip</code> exists at all.</p> <p>Here's how you did <code>zip</code> before it existed:</p> <...
9
2016-09-22T00:51:29Z
[ "python" ]
Difference between normed plt.xcorr at 0-lag and np.corrcoef
39,628,497
<p>I am working on a cross correlation between two relatively small time series, but in trying to accomplish I am running into a problem I cannot reconcile myself. To begin, I understand the dependence between <code>plt.xcorr</code> and <code>np.correlate</code>. However, I am having trouble reconciling the difference ...
1
2016-09-22T00:35:58Z
39,638,088
<p>I used <a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr" rel="nofollow">http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr</a></p> <blockquote> <p>normed : boolean, optional, default: True</p> <p>if True, normalize the data by the autocorrelation at the 0-th lag.</p> ...
0
2016-09-22T11:43:55Z
[ "python", "numpy", "correlation", "cross-correlation" ]
Difference between normed plt.xcorr at 0-lag and np.corrcoef
39,628,497
<p>I am working on a cross correlation between two relatively small time series, but in trying to accomplish I am running into a problem I cannot reconcile myself. To begin, I understand the dependence between <code>plt.xcorr</code> and <code>np.correlate</code>. However, I am having trouble reconciling the difference ...
1
2016-09-22T00:35:58Z
39,639,272
<p>Calculation of standard "Pearson product-moment correlation coefficient" is using samples, shifted by mean values. Cross-correlation coefficient doesn't use normalized samples. Other than than, computation is similar. But still those coefficients have different formulas and different meaning. They are equal only if ...
1
2016-09-22T12:37:10Z
[ "python", "numpy", "correlation", "cross-correlation" ]
Get the return in a function in other function?
39,628,755
<p>Is there any way to access to the return in a function inside other function ?</p> <p>Probably the next code explain more what I want to do.</p> <pre><code>class perro: def coqueta(self, num1, num2): self.num1 = num1 self.num2 = num2 return self.num1 + self.num2 def otro_perro(self...
0
2016-09-22T01:11:38Z
39,628,769
<p>Whats wrong with this? </p> <pre><code>mascota = perro() ejemplo = mascota.coqueta(5,5) mascota.otro_perro(ejemplo) </code></pre> <p>or, </p> <pre><code>mascota = perro() mascota.otro_perro(mascota.coqueta(5,5)) </code></pre>
0
2016-09-22T01:13:46Z
[ "python", "function" ]
Get the return in a function in other function?
39,628,755
<p>Is there any way to access to the return in a function inside other function ?</p> <p>Probably the next code explain more what I want to do.</p> <pre><code>class perro: def coqueta(self, num1, num2): self.num1 = num1 self.num2 = num2 return self.num1 + self.num2 def otro_perro(self...
0
2016-09-22T01:11:38Z
39,628,828
<p>Just make it an attribute of the <code>perro</code> class. Thats really the whole point of class, to modularize, organize, and encapsulate your data instead of having to use <code>global</code>s everywhere:</p> <pre><code>class perro: def coqueta(self, num1, num2): self.num1 = num1 self.num2 = n...
0
2016-09-22T01:21:57Z
[ "python", "function" ]
Get the return in a function in other function?
39,628,755
<p>Is there any way to access to the return in a function inside other function ?</p> <p>Probably the next code explain more what I want to do.</p> <pre><code>class perro: def coqueta(self, num1, num2): self.num1 = num1 self.num2 = num2 return self.num1 + self.num2 def otro_perro(self...
0
2016-09-22T01:11:38Z
39,629,074
<p>Either pass the return value of method <code>coqueta()</code> into <code>otro_perro()</code>, or have <code>otro_perro()</code> call <code>coqueta()</code> directly. Your code suggests that you wish to do the first, so write it like this:</p> <pre><code>class Perro: def coqueta(self, num1, num2): result...
2
2016-09-22T01:52:26Z
[ "python", "function" ]
Cross-Domain XML Querying
39,628,914
<p>I have two servers in my organization. One of which is read-only to me (Server A) and the other hosts our knowledge base (Server B). There is an XML file on <strong>Server A</strong> which is refreshed at an unknown interval. This file contains information on the status of various items. I want to be able to display...
0
2016-09-22T01:33:50Z
39,629,788
<p>You have 3 Options options:</p> <ul> <li><p>First: is to allow Server B to access Server A. If you are using apache server you can do this by add this code the apache configuration file and restart apache</p> <p>SetEnvIf Origin "http(s)?://(www.)?(WRITE_IP_OF_SERVER_B_HERE)$" AccessControlAllowOrigin=$0 Header add...
0
2016-09-22T03:30:38Z
[ "jquery", "python", "ajax", "xml", "same-origin-policy" ]
pymunk updated shape filter usage
39,628,923
<p>I am trying to detect the first shape along a segment starting at my player's position, but I do not want to detect the player.</p> <p>In a previous version of pymunk, the pymunk.Space.segment_query_first function accepted an integer as the shape_filter and it only detected shapes within a group of that integer. Th...
2
2016-09-22T01:36:11Z
39,641,351
<p>Yes the shape filter have become more powerful in pymunk 5 (and as a result also a little bit more complicated). The shape filter is supposed to be a <code>ShapeFilter</code> object (but . See the api docs <a href="http://www.pymunk.org/en/latest/pymunk.html#pymunk.ShapeFilter" rel="nofollow">http://www.pymunk.org/e...
0
2016-09-22T14:06:45Z
[ "python", "filter", "shape", "segment", "pymunk" ]
NuGet error while building caffe on Windows with visual studio 2013
39,628,955
<p>I'm trying to build Caffe on Windows in order to use it on Python (by Import caffe) for my Deep Learning project, but I came across a problem while building the Caffe.sln file with Visual Studio 2013, following instructions from this video : <a href="https://www.youtube.com/watch?v=nrzAF2sxHHM" rel="nofollow">https:...
0
2016-09-22T01:40:18Z
39,747,992
<p>I resolved this issue on my system by overwriting the copy of NuGet.exe that was in caffe-master/windows/.nuget with the nuget.exe version that came with glog.0.3.3.0 in NugetPackages\glog.0.3.3.0\build\native\private\</p> <p>Just a heads up since I was trying to follow the same tutorial; after resolving that issue...
0
2016-09-28T12:46:11Z
[ "python", "windows", "visual-studio-2013", "nuget", "caffe" ]
How does Django make tables relating to user,auth,group,session and so on with very first migration?
39,628,985
<p>I am little bit exciting to write my question in here. Normally I searched other questions to figure out my own problem. By the way, this time I couldn't figure out my question by searching it. That's why I am leaving question in here in person.</p> <p>My question is :</p> <p>How does Django framework make initial...
1
2016-09-22T01:43:15Z
39,629,128
<p>There are apps that are included in the project by default. You can see this is the <code>INSTALLED_APPS</code> in the <code>settings.py</code> file of your project. <code>auth_group</code> is a table from <code>django.contrib.auth</code>.</p>
0
2016-09-22T02:03:28Z
[ "python", "django" ]
How to get remote stdout from Ansible python playbook api
39,629,026
<p>I know I can print the std out using the <code>debug</code> module of Ansible like below:</p> <pre><code>--- - hosts: all tasks: - name: list files under /root folder command: ls /root register: out - name: stdout debug: var=out.stdout_lines </code></pre> <p>And from the answer of <a href="http:...
0
2016-09-22T01:47:25Z
39,991,404
<p>here is my answers, you should make a <code>callback</code></p> <pre><code># -*- coding: utf-8 -*- import json from ansible.parsing.dataloader import DataLoader from ansible.vars import VariableManager from ansible.inventory import Inventory from ansible.playbook.play import Play from ansible.executor.task_queue_ma...
0
2016-10-12T05:55:43Z
[ "python", "ansible", "ansible-playbook", "ansible-2.x" ]
Issues with sending lines over netcat to Python
39,629,064
<p>I am piping a program's stdout to netcat: <code>nc -u localhost 50000</code>. Listening on UDP 50000 is a Python program that does something like this:</p> <pre><code> lstsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) lstsock.setblocking(0) while True: print '1' try: tmp ...
1
2016-09-22T01:51:09Z
39,629,948
<p>This Python script worked for me:</p> <pre><code>import socket lstsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) lstsock.bind(('127.0.0.1', 50000)) SOCK_BUFSZ = 4096 counter = 1 while True: print "counter = %s" % counter counter += 1 data, addr = lstsock.recvfrom(SOCK_BUFSZ) print data </...
1
2016-09-22T03:52:00Z
[ "python", "sockets" ]
Dynamic array in Python
39,629,066
<p>I´m trying to delete an specific row and column from a square list "m" iteratively. At the beginning, I used the square list like a square matrix "m" and I tried using the comand "delete" from numpy as follows:</p> <pre><code>from numpy import* import numpy as np m=array([[1,2,3],[4,5,6],[7,8,9]]) #deleting row a...
0
2016-09-22T01:51:18Z
39,634,907
<p>It seems to me that applying <code>np.delete</code> repeatedly to the same matrix does the job: </p> <pre><code>from __future__ import print_function import numpy as np mat = np.array([[1,2,3],[4,5,6],[7,8,9]]) print( "initial mat:\n", mat ) rmlist = [ (2,0), (1,1) ] # a list of (row,col) to be removed # rml...
1
2016-09-22T09:13:49Z
[ "python", "arrays", "dynamic" ]
SWIG return unsigned char * from C to Python
39,629,126
<p>I'm running into a problem with generating an interface for python with underlying C code. I have the following pieces of code:</p> <p>prov.h</p> <pre><code>#include&lt;string.h&gt; #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; unsigned char *out(); </code></pre> <p>prov.c</p> <pre><code>#include "prov.h" u...
0
2016-09-22T02:03:07Z
39,629,256
<p>Either return <code>char*</code> instead, or you can apply the <code>char*</code> typemaps to <code>unsigned char*</code>. You'll also want <code>%newobject</code> to let Python know to free the returned pointer after converting the return result to a Python object.</p> <pre><code>%module prov %{ #include "prov.h"...
0
2016-09-22T02:22:04Z
[ "python", "c", "swig" ]
Python - Why scatter of matplotlib plots points which have negative coordinates, with positive coordinates?
39,629,139
<p>so there is a big trouble in my script : I have done an array with numpy with contains x,y and z coordinates of some points. some of these points have negative coordinates (for x and/or y and/or z). And for reasons I don't understand, when I use the function scatter from matplotlib, it plots all points with positive...
-1
2016-09-22T02:05:45Z
39,661,910
<p>I'm reading your problem as:</p> <blockquote> <p>Why do the circles at negative coordinates <em>on the axis into and out of the page</em> look the same as their absolute value</p> </blockquote> <p>I think your problem is in this line:</p> <pre><code>self.subplota.scatter( self.matrice[:,1], self.matrice...
1
2016-09-23T13:23:11Z
[ "python", "numpy", "matplotlib", "negative-number", "scatter" ]
Python - Why scatter of matplotlib plots points which have negative coordinates, with positive coordinates?
39,629,139
<p>so there is a big trouble in my script : I have done an array with numpy with contains x,y and z coordinates of some points. some of these points have negative coordinates (for x and/or y and/or z). And for reasons I don't understand, when I use the function scatter from matplotlib, it plots all points with positive...
-1
2016-09-22T02:05:45Z
39,689,200
<p>Sorry since I put this message I try run again my scripts and for reasons I still don't get it works ! And the capture I put at the beginning of my message is the good one. I think maybe it's a problem of reloading new datas in python, Maybe I should have restart a session to get those things right... So, If anybody...
0
2016-09-25T16:31:11Z
[ "python", "numpy", "matplotlib", "negative-number", "scatter" ]
Create a 2D plot pixel grid based on a pandas series of lists
39,629,183
<p>Suppose we have a pandas Series of lists where each list contains some characteristics described as strings like this:</p> <pre><code>0 ["A", "C", "G", ...] 1 ["B", "C", "H", ...] 2 ["A", "X"] ... N ["J", "K", ...] </code></pre> <p>What would be the best/easiest way to plot a 2D pixel grid where the X axis is ...
0
2016-09-22T02:12:31Z
39,633,983
<p>Using pandas for a 1D histrogram seems to be straightfoward as in <a href="http://stackoverflow.com/questions/28418988/how-to-make-a-histogram-from-a-list-of-strings-in-python">this</a> answer. You could use this idea and fill an array of N by 26 and then plot in 2D with </p> <pre><code>import matplotlib.pyplot as ...
1
2016-09-22T08:30:23Z
[ "python", "pandas", "matplotlib", "plot", "series" ]
Create a 2D plot pixel grid based on a pandas series of lists
39,629,183
<p>Suppose we have a pandas Series of lists where each list contains some characteristics described as strings like this:</p> <pre><code>0 ["A", "C", "G", ...] 1 ["B", "C", "H", ...] 2 ["A", "X"] ... N ["J", "K", ...] </code></pre> <p>What would be the best/easiest way to plot a 2D pixel grid where the X axis is ...
0
2016-09-22T02:12:31Z
39,642,909
<p>Since I already wrote the code for the image in my comment, and Ed seems to have the same interpretation of your question as I do, I'll go ahead and add my solution.</p> <pre><code>import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import string M, N = 100, 10 letters = li...
2
2016-09-22T15:18:34Z
[ "python", "pandas", "matplotlib", "plot", "series" ]
SFTP with an SSH ProxyCommand in python
39,629,209
<p>I am downloading some files with the following SSH config:</p> <pre><code>Host proxy Hostname proxy.example.com User proxyuser IdentityFile ~/.ssh/proxy_id_rsa Host target # uses password auth Hostname target.example.com User targetuser ProxyCommand ssh p...
0
2016-09-22T02:16:40Z
39,629,352
<p>Solved with the following:</p> <pre><code>class PatchedProxyCommand(ProxyCommand): # work around https://github.com/paramiko/paramiko/issues/789 @property def closed(self): return self.process.returncode is not None @property def _closed(self): # Concession to Python 3 socket-l...
0
2016-09-22T02:34:22Z
[ "python", "ssh", "proxy", "sftp", "paramiko" ]
What does the code zip( *sorted( zip(units, errors) ) ) do?
39,629,253
<p>For my application <code>units</code> and <code>errors</code> are always lists of numerical values. I tried googling what each part does and figured out the firs part of zip. It seems </p> <pre><code> ziped_list = zip(units, errors) </code></pre> <p>simply pairs the units and errors to produce a list as <code>[....
2
2016-09-22T02:21:37Z
39,629,483
<p>If you don't unpack list, then pass to argument as one element, so zip can't aggregates elements from each of the iterables. For example:</p> <pre><code>a = [3, 2, 1,] b = ['a', 'b', 'c'] ret = zip(a, b) the_list = sorted(ret) the_list &gt;&gt; [(1, 'c'), (2, 'b'), (3, 'a')] </code></pre> <p><code>zip(*the_list)...
2
2016-09-22T02:50:00Z
[ "python" ]
What does the code zip( *sorted( zip(units, errors) ) ) do?
39,629,253
<p>For my application <code>units</code> and <code>errors</code> are always lists of numerical values. I tried googling what each part does and figured out the firs part of zip. It seems </p> <pre><code> ziped_list = zip(units, errors) </code></pre> <p>simply pairs the units and errors to produce a list as <code>[....
2
2016-09-22T02:21:37Z
39,629,666
<p>Seems you've already figured out what <code>zip</code> does. </p> <p>When you sort the zipped list, <code>sorted</code> compares the first element of each tuple, and sorts the list. If the first elements are equal, the order is determined by the second element. </p> <p>The <code>*</code> operator then unpacks th...
1
2016-09-22T03:13:52Z
[ "python" ]
How could I close Excel file using pywinauto
39,629,324
<p>I'm having a problem that I can't excel file.</p> <p>I was using swapy+pywinauto.<br> program export excel file with different name (ex. time..) I used swapy to close the export excel.</p> <pre><code>from pywinauto.application import Application app = Application().Start(cmd_line=u'"C:\\Program Files\\Microsoft O...
0
2016-09-22T02:31:34Z
39,638,436
<p>Why do you use <code>app.XLMAIN</code>? Is the title of window similar to <code>XLMAIN</code>? Usually the title is <code>&lt;file name&gt; - Excel</code> so that pywinauto can handle it so: <code>xlmain = app["&lt;file name&gt; - Excel"]</code>.</p> <p>Obviously <code>Wait('ready')</code> raised an exception becau...
1
2016-09-22T11:58:38Z
[ "python", "excel", "pywinauto" ]
numpy.genfromtxt flattens my data
39,629,337
<p>I have <code>row.csv</code></p> <pre><code>1, 2, 3, 4, 5 </code></pre> <p>and <code>column.csv</code></p> <pre><code>1, 2, 3, 4, 5 </code></pre> <p><code>numpy.genfromtxt("one-of-the-above.csv", delimiter=",")</code> reads them into the same array: <code>np.array([1,2,3,4,5])</code></p> <p>but I would like to g...
1
2016-09-22T02:33:05Z
39,629,395
<p>That is a "feature" of <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html" rel="nofollow"><code>genfromtxt</code></a>. Before it returns the data that it read from the file, it uses <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.squeeze.html" rel="nofollow"><code>...
1
2016-09-22T02:38:44Z
[ "python", "numpy" ]
SoftLayer Api: How to get the currently consume of bandwidth packet traffic data?
39,629,340
<p>I have a sl-vm which pay mode is monthly. I have buy it a bandwidth packet 250G. The sl website shows this vm's bandwidth usage is 34.18MB, as shown in flowing Fig: <a href="http://i.stack.imgur.com/p43t3.png" rel="nofollow"><img src="http://i.stack.imgur.com/p43t3.png" alt="enter image description here"></a></p> ...
0
2016-09-22T02:33:39Z
39,648,394
<p>Please use the “IEEE notation: kilobyte = 1000 bytes”, it means that you need to do the following: <code>45500302/1000/1000 =45.5</code>. There are some variations between UI and API values.</p> <p>You can use this online tool:</p> <p><a href="http://www.matisse.net/bitcalc/?input_amount=45500302&amp;input_un...
0
2016-09-22T20:33:48Z
[ "python", "api", "softlayer" ]
input function does not work & returns FileInput object
39,629,406
<p>I'm trying to get user input as function call in a small python program but, when i'm using the <code>input()</code> method, python shell does not let me input anything and quit by itself.</p> <pre><code>from fileinput import input def funcinput(): comm = input("--&gt;") print('your input is %s' %comm) if...
1
2016-09-22T02:40:08Z
39,629,453
<p>The cause here is a masking of the built-in <a href="https://docs.python.org/3.6/library/functions.html#input" rel="nofollow"><code>input</code></a>. In some point, a <code>from fileinput import input</code> occurs, which masks <code>builtins.input</code> and replaces it with <a href="https://docs.python.org/3.6/lib...
2
2016-09-22T02:45:59Z
[ "python", "python-3.x", "input" ]
Writing terminal output to terminal and to a file?
39,629,435
<p>I have different functions which is giving string and text output in the terminal during excecution of the function. The command I have used is <code>sys.stdout.write</code></p> <p>In one of the function I am creating a file and calling those functions mentioned above. When running this function I need to write all...
1
2016-09-22T02:44:05Z
39,629,459
<pre><code>import sys def func1(): sys.stdout.write('A') sys.stdout.write('B') def func2(): sys.stdout.write('C') sys.stdout.write('D') class MyCoolOs: def __init__(self,stdout,f): self.stdout = stdout self.f = f def write(self,s): self.f.write(s) self.stdout.write(s) def main(): f=...
1
2016-09-22T02:47:12Z
[ "python" ]
Writing terminal output to terminal and to a file?
39,629,435
<p>I have different functions which is giving string and text output in the terminal during excecution of the function. The command I have used is <code>sys.stdout.write</code></p> <p>In one of the function I am creating a file and calling those functions mentioned above. When running this function I need to write all...
1
2016-09-22T02:44:05Z
39,629,587
<p>Use a context manager to create a wrapper that writes to a file and <code>stdout</code>:</p> <pre><code>class Tee(object): def __init__(self, log_file_name, stdout): self.log_file_name = log_file_name self.stdout = stdout def __enter__(self): self.log_file = open(self.log_file_name,...
1
2016-09-22T03:04:04Z
[ "python" ]
identify csv in python
39,629,443
<p>I have a data dump that is a "messed up" CSV. (About 100 files, each with about 1000 lines of actual CSV data.)<br> The dump has some other text in addition to CSV. How can I extract the CSV part separately, programmatically?</p> <p>As an example the data file looks like something like this</p> <pre><code>Session:...
0
2016-09-22T02:44:58Z
39,629,694
<p>If your csv lines and only those lines start with \", then you can do this:</p> <pre><code>import csv data = list(csv.reader(open("test.csv", 'rb'), quotechar='¬')) # for quotechar - use something that won't turn up in data def importCSV(data): # outputs list of list with required data # works on the ass...
0
2016-09-22T03:18:09Z
[ "python", "csv" ]
identify csv in python
39,629,443
<p>I have a data dump that is a "messed up" CSV. (About 100 files, each with about 1000 lines of actual CSV data.)<br> The dump has some other text in addition to CSV. How can I extract the CSV part separately, programmatically?</p> <p>As an example the data file looks like something like this</p> <pre><code>Session:...
0
2016-09-22T02:44:58Z
39,629,720
<p>How about this:</p> <pre><code>import re my_pattern = re.compile("(\"[\w]+\",)+") with open('&lt;your_file&gt;', 'rb') as fi: for f in fi: result = my_pattern.match(f) if result: print f </code></pre> <p>Assuming the csv data can be differentiated from the rest by having no specia...
1
2016-09-22T03:21:30Z
[ "python", "csv" ]
identify csv in python
39,629,443
<p>I have a data dump that is a "messed up" CSV. (About 100 files, each with about 1000 lines of actual CSV data.)<br> The dump has some other text in addition to CSV. How can I extract the CSV part separately, programmatically?</p> <p>As an example the data file looks like something like this</p> <pre><code>Session:...
0
2016-09-22T02:44:58Z
39,629,967
<p>Can you not read each line and do a regex to see weather or not to pull the data? Maybe something like:</p> <p>^(["][\w]<em>["][,])+["][\w]</em>["]$</p> <p>My regex is not the best and there may likely be a better way but that seemed to work for me.</p>
0
2016-09-22T03:54:25Z
[ "python", "csv" ]
Printed items from LISt do not match what was inserted
39,629,464
<p>Sorry guys, a bit new to Python so please bear with me.</p> <p>I am attempting, just for S and G's to create a small python program that will take X number of digits of Pi, and play them as winsound.beeps (don't ask).</p> <p>I got the beeps to beep, and I got Pi inserted into a list. When i print the list, it's no...
0
2016-09-22T02:47:38Z
39,629,488
<p>Use the following as your last for loop:</p> <pre><code>for number in listPi: print(number) </code></pre> <p>the for loop gives you the contents in the list one by one. You don't need to look up in the list again.</p>
0
2016-09-22T02:50:36Z
[ "python", "list", "python-2.7" ]
Printed items from LISt do not match what was inserted
39,629,464
<p>Sorry guys, a bit new to Python so please bear with me.</p> <p>I am attempting, just for S and G's to create a small python program that will take X number of digits of Pi, and play them as winsound.beeps (don't ask).</p> <p>I got the beeps to beep, and I got Pi inserted into a list. When i print the list, it's no...
0
2016-09-22T02:47:38Z
39,629,504
<p>The code should be ,</p> <pre><code>for number in listPi: print(number) </code></pre> <p>Cause here you are iterating through the contents of the list not the keys associated with them , for example take the first case where it is <code>print(listPi[number])</code> it essentially prints <code>lisPi[3]</code> w...
0
2016-09-22T02:52:10Z
[ "python", "list", "python-2.7" ]
Using if for multiple input lists in Python list comprehension
39,629,591
<p>How do you use an if statement in a list comprehension when there are multiple input lists. Here is the code that I'm using and the error that I'm getting: </p> <p>(I get that it's not able to apply modulus to a list, but not sure how to specifically reference the x in each of the lists as it iterates through them...
0
2016-09-22T03:04:15Z
39,629,616
<p>This isn't a cause with the <code>if</code> statement, the issue here is with <code>x in (a, b)</code>. When that executes, <code>x</code> takes on a <code>list</code> value (first <code>a</code>, then <code>b</code>) and then Python will try try to execute your <code>if</code> condition on it, an expression of the ...
3
2016-09-22T03:07:22Z
[ "python", "python-3.x", "list-comprehension" ]
Using if for multiple input lists in Python list comprehension
39,629,591
<p>How do you use an if statement in a list comprehension when there are multiple input lists. Here is the code that I'm using and the error that I'm getting: </p> <p>(I get that it's not able to apply modulus to a list, but not sure how to specifically reference the x in each of the lists as it iterates through them...
0
2016-09-22T03:04:15Z
39,629,737
<p>As Jim said, you are <code>mod</code> a list to a <code>int</code>.</p> <p>You can also use <code>+</code>, e.g., <code>nums = [x**2 for x in a+b if x%2==0]</code>.</p>
1
2016-09-22T03:24:17Z
[ "python", "python-3.x", "list-comprehension" ]
Not able to move image in Pygame
39,629,679
<p>I am a beginner in Python. I am trying to shift image using pygame module. But I am not able to shift position of the image in python. Can you help me understand what I am doing wrong?</p> <pre><code>import pygame, sys from pygame.locals import * pygame.init() ...
0
2016-09-22T03:14:56Z
39,630,580
<p>A basic game loop should do three things: handle events, update and draw. I see the logic where you update the position of the rectangle, but you don't redraw the image at the new position.</p> <p>I've added lines at the bottom of the game loop to draw the scene.</p> <pre><code>while True: # handle events ...
1
2016-09-22T04:57:22Z
[ "python", "pygame" ]
Python "IndentationError: expected an indented block" After Checking Indentation
39,629,684
<p>I keep getting the following error even though I've checked all the idents to make sure they're indents and not spaces:</p> <p>File "", line 13 """</p> <p>^ IndentationError: expected an indented block</p> <pre><code>import random def guess_the_number(): number, guesses = random.randint( 1, 20 ), 1 ...
0
2016-09-22T03:16:27Z
39,629,977
<p>Also for your further references, it is recommended by the <a href="https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces" rel="nofollow">Style Guide for Python Code</a> that </p> <blockquote> <p>Spaces are the preferred indentation method. Tabs should be used solely to remain consistent with code that is al...
0
2016-09-22T03:55:10Z
[ "python", "python-3.x" ]
Python multidimensional array list index out of range
39,629,728
<p>I'm trying to make a program that will read a text file of names and numbers and make it into a 2d array with the names and numbers, then remove the item from the array if the number is 1. However, the code I wrote to access the index in the 2d array doesn't work and throws the error "IndexError: list index out of r...
0
2016-09-22T03:23:09Z
39,629,797
<p>In case you just want to remove some elements from the list you could iterate it from end to beginning which would allow you to remove items without causing <code>IndexError</code>:</p> <pre><code>list2 = [["John Doe","1"],["Jane Smith","0"],["Firstname Lastname","1"]] for i in range(len(list2) - 1, -1, -1): l...
0
2016-09-22T03:32:05Z
[ "python", "arrays", "multidimensional-array", "indexoutofrangeexception" ]
How to plot pie charts as subplots with custom size with Plotly in Python
39,629,735
<p>I've been trying to make a grid of subplots with custom size with Plotly(version 1.12.9) in Jupyter notebook(offline). There is nice examples in the Plotly website but all of them are with scattered plots. I modified one of them to make it look like the one I want to and it works with scatter plots:</p> <pre><code>...
2
2016-09-22T03:24:13Z
40,076,205
<p>I recently struggled with the same problem, and found nothing about whether we can use <code>plotly.tools.make_subplots</code> with <code>plotly.graph_objs.Pie</code>. As I understand this is not possible because these plots have no x and y axes. In the <a href="https://plot.ly/python/pie-charts/" rel="nofollow">ori...
0
2016-10-16T22:31:33Z
[ "python", "jupyter-notebook", "plotly" ]
TypeError at /post/ render_to_response() got an unexpected keyword argument 'context_instance'
39,629,793
<p>I am trying to preview form before saving using 'formtools'. When I visit post it gives following errors: Request Method: GET Request URL: <a href="http://127.0.0.1:8000/post/" rel="nofollow">http://127.0.0.1:8000/post/</a></p> <pre><code>Django Version: 1.10.1 Python Version: 3.5.2 Installed Applications: ['django...
0
2016-09-22T03:31:22Z
39,631,415
<p><code>formtools</code> not supported the <code>Django 1.10</code> version please <code>downgrade</code> your Django release for the workaround.</p> <blockquote> <p><a href="https://github.com/django/django-formtools/issues/75" rel="nofollow">https://github.com/django/django-formtools/issues/75</a></p> </blockquot...
1
2016-09-22T06:05:23Z
[ "python", "django" ]
TypeError at /post/ render_to_response() got an unexpected keyword argument 'context_instance'
39,629,793
<p>I am trying to preview form before saving using 'formtools'. When I visit post it gives following errors: Request Method: GET Request URL: <a href="http://127.0.0.1:8000/post/" rel="nofollow">http://127.0.0.1:8000/post/</a></p> <pre><code>Django Version: 1.10.1 Python Version: 3.5.2 Installed Applications: ['django...
0
2016-09-22T03:31:22Z
39,652,201
<p>I solved it by some changes in lib/python3.5/site-packages/formtools/preview.py file. Here I first changes render_to_response to render and then removed context_instance=RequestContext(request) from argument. Suppose post_post method now look like:</p> <pre><code> def post_post(self, request): """ V...
1
2016-09-23T03:39:56Z
[ "python", "django" ]
I using python and the module of multiprocess,but when I use global,that have error,the global name is not defined
39,629,795
<p>hello,I want to compare the distributed database to the postgresql</p> <p>using <code>python</code>,and using <code>multiprocessing</code> to simulate multi-role</p> <p>I want to create the 4 random and calculate their running time</p> <p>but when I defined the 4 random as global,that prompt </p> <blockq...
0
2016-09-22T03:31:51Z
39,630,182
<p>The error is from multicitus(), while making the string for sqlcitus.</p> <p>I think you want to get global variables a, b, c, d declared and assigned in multitest(). But the problem is that multicitus() and sqlcitus() are in different processes, and it is impossible for them to share any global variables. Global v...
1
2016-09-22T04:18:01Z
[ "python", "parallel-processing", "global" ]
Inserting NULL value to a double data type MySQL Python
39,629,823
<p>I have a table. This is the create statement. </p> <pre><code> CREATE TABLE `runsettings` ( `runnumber` mediumint(9) NOT NULL, `equipment` varchar(45) NOT NULL, `wafer` varchar(45) NOT NULL, `settingname` varchar(100) NOT NULL, `float8value` double DEFAULT NULL, `apcrunid` varchar(45) DEFAULT NULL, ...
3
2016-09-22T03:37:36Z
39,630,463
<p>This is not entirely suprising. In the first instance you are inserting the python predefined constant <a href="https://docs.python.org/2/library/constants.html" rel="nofollow">None</a></p> <blockquote> <p>The sole value of types.NoneType. None is frequently used to represent the absence of a value, as when def...
3
2016-09-22T04:47:09Z
[ "python", "mysql", "prepared-statement" ]
Write Pandas Series Vertically using to_csv
39,629,852
<p>I have a loop running that has a long series that needs to be printed vertically to a csv on each iteration. Using the to_csv is just printing it horizontally. Is there a specific way this needs be done?</p> <pre><code>Index Value Age 25 Siblings 0 Area Code 416 ...etc Age ...
0
2016-09-22T03:40:17Z
39,630,047
<p>This will work for you:</p> <pre><code>idx = s.index.unique() df = pd.DataFrame(dict(zip(idx, [s[i].tolist() for i in idx]))) df.to_csv('file.csv') </code></pre>
0
2016-09-22T04:03:59Z
[ "python", "pandas" ]
Write Pandas Series Vertically using to_csv
39,629,852
<p>I have a loop running that has a long series that needs to be printed vertically to a csv on each iteration. Using the to_csv is just printing it horizontally. Is there a specific way this needs be done?</p> <pre><code>Index Value Age 25 Siblings 0 Area Code 416 ...etc Age ...
0
2016-09-22T03:40:17Z
39,630,640
<p>Have you tried transposing the df and then outputting it? </p> <pre><code>dfT = df.T dfT.to_csv('Vert.csv') </code></pre> <p>Something like that might give you what you want. Similar to this <a href="http://stackoverflow.com/questions/24412510/transpose-pandas-dataframe">question</a>. </p>
0
2016-09-22T05:03:03Z
[ "python", "pandas" ]
How to uninstall python jupyter correctly?
39,629,879
<p>I have <code>jupyter</code> installed with <code>python3.5</code> on my <em>Mac OSX</em>, but I want the <code>python2.7</code> version. So, I basically need to uninstall the <code>3.5</code> version, and reinstall the <code>2.7</code> version. </p> <p>But for some reason I can't uninstall the 3.5 version. I tri...
2
2016-09-22T03:42:49Z
39,649,697
<p>Use pip3 instead of pip</p> <pre><code>pip3 uninstall jupyter </code></pre> <p>You can install for both python 2 and python 3 on the same computer as long as you use the correct pip version</p>
0
2016-09-22T22:14:42Z
[ "python", "ipython", "jupyter", "jupyter-notebook" ]
Python Minibatch Dictionary Learning
39,629,931
<p>I'd like to implement error tracking with dictionary learning in python, using sklearn's <a href="http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.MiniBatchDictionaryLearning.html" rel="nofollow">MiniBatchDictionaryLearning</a>, so that I can record how the error decreases over the iterations. ...
2
2016-09-22T03:50:03Z
39,633,530
<p>Each call to <code>fit</code> re-initializes the model and forgets any previous call to <code>fit</code>: this is the expected behavior of all estimators in scikit-learn.</p> <p>I think using <code>partial_fit</code> in a loop is the right solution but you should call it on small batches (as done in the fit method ...
1
2016-09-22T08:04:56Z
[ "python", "numpy", "scikit-learn" ]
What is the best way to represent or shape data with >700 features for classification?
39,630,178
<p>I have a train data file that contains 0 or 1 class labels with a string containing numbers. The string is the molecular structure of the drug with a class label.</p> <p>The file looks like this: </p> <pre><code>0 1730 2281 2572 2602 2611 2824 2855 2940 3149 3313 3560 3568 3824 4185 4266 4366 4409 4472 5008 5114...
0
2016-09-22T04:17:44Z
39,630,379
<p>You need to vectorize your data so that you have a square matrix with one column for each possible value. You can do this using a <code>CountVectorizer</code> (this is usually used for processing text but it will work for your data as well). The output will be a sparse matrix, depending on the model that you want to...
1
2016-09-22T04:38:59Z
[ "python", "pandas", "scikit-learn", "classification", "data-representation" ]
cannot load Python 3.5 interpreter for virtualenv
39,630,188
<p>I have installed Python 3.5 through Anaconda on the OSX system. After installing and activating the virtual environment, </p> <pre><code>virtualenv venv source venv/bin/activate </code></pre> <p>The Python version is Python 2.7.10. And while we are allowed to load the interpreter of our choice in <a href="http://d...
0
2016-09-22T04:18:34Z
39,630,906
<pre><code>ERROR: The executable venv/bin/python3.5 is not functioning ERROR: It thinks sys.prefix is '/Users/Username/.../targetfolder' (should be '/Users/Username/.../targetfolder/venv') ERROR: virtualenv is not compatible with this system or executable </code></pre> <p>This error results from trying to combine inco...
0
2016-09-22T05:27:37Z
[ "python", "python-2.7", "python-3.x", "virtualenv" ]
python is there an inbuilt in way to return a list generator instead of list from random.sample
39,630,193
<p>I use <code>random.sample</code> to sample from a very large range depending on the input load. Sometimes the sample itself is very large and since it is a list it occupies a lot of memory.</p> <p>The application does not necessarily use all the value in the list. It would be great if <code>random.sample</code> ca...
0
2016-09-22T04:18:57Z
39,631,306
<p>Since you commented that the order doesn't matter (I had asked whether it must be random or can be sorted), this might be an option:</p> <pre><code>import random def sample(n, k): """Generate random sorted k-sample of range(n).""" for i in range(n): if random.randrange(n - i) &lt; k: yi...
2
2016-09-22T06:00:00Z
[ "python", "random" ]
python is there an inbuilt in way to return a list generator instead of list from random.sample
39,630,193
<p>I use <code>random.sample</code> to sample from a very large range depending on the input load. Sometimes the sample itself is very large and since it is a list it occupies a lot of memory.</p> <p>The application does not necessarily use all the value in the list. It would be great if <code>random.sample</code> ca...
0
2016-09-22T04:18:57Z
39,631,828
<p>Why not something like the following -- the set <code>seen</code> only grows to a function of <code>k</code>, not necessarily to the size of <code>population</code>:</p> <pre><code>import random def sample(population, k): seen = set() for _ in range(k): element = random.randrange(population) ...
1
2016-09-22T06:32:47Z
[ "python", "random" ]
Decrease the cost of two lists comparisons
39,630,255
<p>I want to minimize the cost of comparisons of two lists that have some words. In the code below <code>A</code> has 4 words whereas <code>B</code> has 2 words and the cost is <code>O(n^2)</code> that is too bad. While for 100 words it can be time consuming. Can I minimize it somehow?</p> <pre><code>A= ["helry", "joh...
0
2016-09-22T04:26:04Z
39,630,276
<ol> <li>Sort array for O(nlogn) first.</li> <li>Compare it in O(n), because you can safely assume the relationship between certain elements are the same after sorting.</li> </ol>
0
2016-09-22T04:27:41Z
[ "python", "time-complexity" ]
Decrease the cost of two lists comparisons
39,630,255
<p>I want to minimize the cost of comparisons of two lists that have some words. In the code below <code>A</code> has 4 words whereas <code>B</code> has 2 words and the cost is <code>O(n^2)</code> that is too bad. While for 100 words it can be time consuming. Can I minimize it somehow?</p> <pre><code>A= ["helry", "joh...
0
2016-09-22T04:26:04Z
39,630,796
<ol> <li><code>O(nlogn)</code> for sorting <code>A</code>. </li> <li>use a binary search for each element of <code>B</code> in <code>A</code> Iit'll take <code>O(log n)</code>. For <code>m</code> elements in <code>B</code>, it'll be <code>O(m*logn)</code>.</li> </ol> <p>(or) if you use hash, you can do in <code>O(m)</...
0
2016-09-22T05:18:30Z
[ "python", "time-complexity" ]
Decrease the cost of two lists comparisons
39,630,255
<p>I want to minimize the cost of comparisons of two lists that have some words. In the code below <code>A</code> has 4 words whereas <code>B</code> has 2 words and the cost is <code>O(n^2)</code> that is too bad. While for 100 words it can be time consuming. Can I minimize it somehow?</p> <pre><code>A= ["helry", "joh...
0
2016-09-22T04:26:04Z
39,631,095
<p>Use sets instead of lists (btw these are not called arrays in Python). What you want is the intersection of two sets, which is (on average) <code>O(min(len(A), len(B))</code> (<a href="https://wiki.python.org/moin/TimeComplexity" rel="nofollow">https://wiki.python.org/moin/TimeComplexity</a>). And since this algorit...
1
2016-09-22T05:42:53Z
[ "python", "time-complexity" ]
Decrease the cost of two lists comparisons
39,630,255
<p>I want to minimize the cost of comparisons of two lists that have some words. In the code below <code>A</code> has 4 words whereas <code>B</code> has 2 words and the cost is <code>O(n^2)</code> that is too bad. While for 100 words it can be time consuming. Can I minimize it somehow?</p> <pre><code>A= ["helry", "joh...
0
2016-09-22T04:26:04Z
39,634,797
<p>You can do it in <em>O(n)</em> time with sets and testing for <em>membership</em> with <code>in</code>, you still have to iterate over all the names In <code>A</code> but checking if each name is in the setof name is <code>O(1)</code>:</p> <pre><code>A = ["helry", "john" , "kat" , "david"] d = "Helry David" st = se...
0
2016-09-22T09:08:55Z
[ "python", "time-complexity" ]
python: socket.sendall() hogs GIL?
39,630,326
<p>i have a multithreaded program (about 20 threads; a mixture of producer/consumers with many queues)</p> <p>in one of the threads, it pops strings from a queue and send it to a remote program</p> <pre><code># it starts the thread like this workQ = Queue.Queue() stop_thr_event = threading.Event() t = threading.Threa...
1
2016-09-22T04:33:05Z
39,630,616
<p>You're wrong. No network activities hold GIL and sendall() is not an exception!</p> <pre><code>item=workQ.get() socket.sendall() **# may take long time here.** workQ.task_done() </code></pre> <p>Because sendall() may take long time and other threads which use workQ <strong>can not take turn to run before you call...
1
2016-09-22T05:00:03Z
[ "python", "multithreading", "sockets", "deadlock", "hang" ]
python: socket.sendall() hogs GIL?
39,630,326
<p>i have a multithreaded program (about 20 threads; a mixture of producer/consumers with many queues)</p> <p>in one of the threads, it pops strings from a queue and send it to a remote program</p> <pre><code># it starts the thread like this workQ = Queue.Queue() stop_thr_event = threading.Event() t = threading.Threa...
1
2016-09-22T04:33:05Z
39,631,506
<p>GIL-hogging will not cause a program to hang. It may harm the performance of the program, but this is a far cry from hanging. It is much more likely that you are experiencing some form of <a href="http://en.wikipedia.org/wiki/Deadlock" rel="nofollow">deadlock</a>. The GIL cannot participate in a deadlock because ...
1
2016-09-22T06:11:34Z
[ "python", "multithreading", "sockets", "deadlock", "hang" ]
Python v3 using idle with Tkinter and Gui, repeating code
39,630,410
<p>I am having some trouble with my code and was wondering if anyone could help me?</p> <p>I have made a program with two classes that ae designed to act as a phone ordering system. This is based on the company Subway. You can see the gui this code produces here: <a href="http://i.stack.imgur.com/dvkYL.png" rel="nofo...
0
2016-09-22T04:42:15Z
39,630,902
<p>Firstly, you should directly post the relevant code, not links.</p> <p>Just based on what you wrote, you can have the button add data to a list instead of an arbitrary number of distinct variables. That way, the list can hold any number of sandwich orders.</p> <pre><code>mylist = [] mylist.append('chicken sub') my...
1
2016-09-22T05:27:22Z
[ "python", "tkinter" ]
How to href the elements in a python list with Flask?
39,630,416
<p>How can I transform to different html hrefs the elements of a list?. For instance:</p> <pre><code>A = [string1, string2, ..., stringN] </code></pre> <p>To:</p> <p><code>A = [</code><a href="https://this_is_url_1/" rel="nofollow"><code>string1</code></a><code>,</code> <a href="https://this_is_url_2/" rel="nofollow...
1
2016-09-22T04:42:40Z
39,630,495
<pre><code>strings = ['the','quick','brown','fox'] result = ['&lt;a href="http://this_is_url_{}"&gt;{}&lt;/a&gt;'.format(a,a) for a in strings] </code></pre>
1
2016-09-22T04:50:36Z
[ "python" ]
How to href the elements in a python list with Flask?
39,630,416
<p>How can I transform to different html hrefs the elements of a list?. For instance:</p> <pre><code>A = [string1, string2, ..., stringN] </code></pre> <p>To:</p> <p><code>A = [</code><a href="https://this_is_url_1/" rel="nofollow"><code>string1</code></a><code>,</code> <a href="https://this_is_url_2/" rel="nofollow...
1
2016-09-22T04:42:40Z
39,630,522
<p>Your question is not clear and ambiguous.</p> <p>If string is hyperlink..</p> <pre><code>A = [string1, string2, ..., stringN] </code></pre> <p><code>hrefs = ['&lt;a href="%s"&gt;%s&lt;/a&gt;' % (a,a) in A]</code></p>
0
2016-09-22T04:52:51Z
[ "python" ]
Spatial index to find points within polygon, if points and polygon have same minimum bounding box
39,630,501
<p>I have a shapely <em>polygon</em> representing the boundaries of the city of Los Angeles. I also have a set of ~1 million lat-long <em>points</em> in a geopandas GeoDataFrame, all of which fall within that polygon's minimum bounding box. Some of these points lie within the polygon itself, but others do not. I want t...
1
2016-09-22T04:51:03Z
39,651,929
<p>A little example to duplicate the problem a bit</p> <pre><code>import pandas as pd import shapely import matplotlib.pyplot as plt from matplotlib.collections import PatchCollection from matplotlib.patches import Polygon from shapely.geometry import Point import seaborn as sns import numpy as np # some lon/lat poi...
1
2016-09-23T03:05:31Z
[ "python", "gis", "geospatial", "shapely", "geopandas" ]
Time stamp representation in digits in a tsv to standard formate
39,630,508
<p>I have a text file and it contains data of the activities of online Facebook and Twitter users i.e. PostID or userID. These IDs are represented in decimal. For example "PostID":4038363805081732322.But the problem is that there is one column where time stamp of the post is also represented in decimal format e.g "Post...
-1
2016-09-22T04:51:46Z
39,630,964
<p>This is epoch time, from the python library: "time.ctime([secs])" - Convert a time expressed in seconds since the epoch to a string representing local time. If secs is not provided or None, the current time as returned by time() is used. ctime(secs) is equivalent to asctime(localtime(secs)). Locale information ...
0
2016-09-22T05:32:13Z
[ "python" ]
A print function makes a multiprocessing program fail
39,630,676
<p>In the following code, I'm trying to create a sandboxed master-worker system, in which changes to global variables in a worker don't reflect to other workers.</p> <p>To achieve this, a new process is created each time a task is created, and to make the execution parallel, the creation of processes itself is managed...
4
2016-09-22T05:07:10Z
39,631,629
<p>You are not creating ThreadPoolExecutor every time , rather using the pre initialized pool for every iteration. I really not able to track which print statement is hindering you?</p>
0
2016-09-22T06:19:57Z
[ "python", "python-3.x", "python-multithreading", "python-multiprocessing" ]
A print function makes a multiprocessing program fail
39,630,676
<p>In the following code, I'm trying to create a sandboxed master-worker system, in which changes to global variables in a worker don't reflect to other workers.</p> <p>To achieve this, a new process is created each time a task is created, and to make the execution parallel, the creation of processes itself is managed...
4
2016-09-22T05:07:10Z
39,653,112
<p>Try using</p> <pre><code>from multiprocessing import set_start_method ... rest of your code here .... if __name__ == '__main__': set_start_method('spawn') main() </code></pre> <p>If you search Stackoverflow for python multiprocessing and multithreading you will find a a fair few questions mentioning simi...
1
2016-09-23T05:20:50Z
[ "python", "python-3.x", "python-multithreading", "python-multiprocessing" ]
Django, How does models.py under auth folder create initial tables when you migrate very first time?
39,630,773
<p>If you migrate very first time after making new project in Django, you can find that Django creates tables like below.</p> <pre><code>auth_group auth_group_permissions auth_permission auth_user auth_user_groups auth_user_user_permissions django_admin_log django_content_type django_migrations django_session </code><...
3
2016-09-22T05:16:42Z
39,630,862
<p>This can be easily explained.</p> <pre><code>auth_user_groups auth_group_permissions auth_user_user_permissions </code></pre> <p>Are relational tables. Which are used to store info about how model tables are related.</p> <p>For example <code>auth_user_groups</code> is storing how users and groups are related. If ...
3
2016-09-22T05:25:11Z
[ "python", "django", "django-models", "migration" ]
Return prompt after accessing nohup.out (bash)
39,630,824
<p>I'm running a Python script from bash using <code>nohup</code>. The script is executed via my bashrc as part of a shell function. If I run it like this:</p> <pre><code>function timer { nohup python path/timer.py $1 $2 &gt; path/nohup.out 2&gt;&amp;1 &amp; echo 'blah' } </code></pre> <p>Everything works an...
0
2016-09-22T05:20:55Z
39,630,883
<p>You won't get prompt. </p> <p>Because, <code>tail -f</code> will always watch the file (<code>path/nohup.out</code>) to output appended data as the file grows. You can try <code>tail -n</code> to get last <code>10</code> lines of <code>path/nohup.out</code>.</p>
0
2016-09-22T05:26:29Z
[ "python", "bash", "shell", "nohup" ]
How to plot a figure with Chinese Characters in label
39,630,928
<p>When I draw a figure with Chinese Character label in Python 3, it doesn't work correctly:</p> <p><img src="http://i.stack.imgur.com/k5zpP.png" alt="Screenshot">]</p> <p><strong>My code:</strong></p> <pre><code>fig = pd.DataFrame({ '债券收益率':bond, '债券型基金收益率':bondFunds, '被动æŒ...
0
2016-09-22T05:29:21Z
39,655,334
<p>You need to explicitly pass the font properties to <code>legend</code> function using the <code>prop</code> kwag:</p> <pre><code>from matplotlib import font_manager fontP = font_manager.FontProperties() fontP.set_family('SimHei') fontP.set_size(14) fig = pd.DataFrame({ '债券收益率':bond, '债券型åŸ...
1
2016-09-23T07:41:48Z
[ "python", "python-3.x", "pandas", "matplotlib" ]
Python can't find packages in Virtual Environment
39,630,944
<p>I'm trying to setup my environment for a project but python isn't able to find the modules I've installed with pip.</p> <p>I did the following:</p> <pre><code>mkdir helloTwitter cd helloTwitter virtualenv myenv Installing setuptools, pip, wheel...done. source myenv/bin/activate pip install tweepy Collecting tweep...
0
2016-09-22T05:30:37Z
39,631,250
<p>It looks like you're manually setting your <code>$PATH</code> to point to your virtual environment. The whole point of the <code>myenv/bin/activate</code> script is to take care of this for you. </p> <p>Once you have activated your virtual environment, any package you install using pip will be placed in the relevan...
3
2016-09-22T05:56:46Z
[ "python", "virtualenv" ]
Python can't find packages in Virtual Environment
39,630,944
<p>I'm trying to setup my environment for a project but python isn't able to find the modules I've installed with pip.</p> <p>I did the following:</p> <pre><code>mkdir helloTwitter cd helloTwitter virtualenv myenv Installing setuptools, pip, wheel...done. source myenv/bin/activate pip install tweepy Collecting tweep...
0
2016-09-22T05:30:37Z
39,650,431
<p>Ok, I think I found a solution, if not an answer. 1. I uninstalled the package and made sure it was not in system or user 2. I re-created the virtual environment. 3. I checked that the environments python and pip were being used. 4. This time when installing my package I added the <code>--no-cache-dir</code> optio...
0
2016-09-22T23:38:50Z
[ "python", "virtualenv" ]