I’m having troubles with installing packages in Python 3. I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get: I have no idea what to do because I didn’t have setuptools installed in the past. Still, I was able to install many package…
Tag: python
How can I see normal print output created during pytest run?
Sometimes I want to just insert some print statements in my code, and see what gets printed out when I exercise it. My usual way to “exercise” it is with existing pytest tests. But when I run these, I don’t seem able to see any standard output (at least from within PyCharm, my IDE). Is there…
displaying fixed width bars for all datasets in matplotlib
I have the following datasets .I need to plot barchats for say 1,2 or all of them.When I plot the chart for a single data item (eg: xdata=[0] and ydata=[1000], xlabels=[‘first’] , the bar is sclaed to occupy the whole plot area.How do I restrict the barwidth to be say 0.45? When I tried I got this…
Edit MP4 metadata using Python
I need to give attributes (meta data) to a file in python code on Linux, specifically Ubuntu. Specifically I need to set the author, title, album, etc. on MP4 files. Answer You could try with Mutagen or Tagpy Both seem very straightforward, but I don’t have any experience with them.
Python Tkinter multiple selection Listbox
I have a listbox which is setup with selection=’multiple’. I then try to obtain a list of all the options the user has selected, by the code name.get(ACTIVE). the problem is that it doesn’t not always get all the options I have highlighted in the listbox GUI. If I highlight one, it brings th…
Reading YAML file with Python results in yaml.composer.ComposerError: expected a single document in the stream
I have a yaml file that looks like I am able to read this correctly in Perl using YAML but not in python using YAML. It fails with the error: expected a single document in the stream Program: Error: Answer The yaml documents are separated by —, and if any stream (e.g. a file) contains more than one docu…
Get size in Bytes needed for an integer in Python
How can I find out the number of Bytes a certain integer number takes up to store? E.g. for hexadecimal x00 – xff (or decimal 0 – 255 = binary 0000 0000 – 1111 1111) I’m looking to get 1 (Byte), hexadecimal x100 – xffff (or decimal 256 – 65535 = binary 0000 0001 0000 0000 &…
Unable to import a module that is definitely installed
After installing mechanize, I don’t seem to be able to import it. I have tried installing from pip, easy_install, and via python setup.py install from this repo: https://github.com/abielr/mechanize. All of this to no avail, as each time I enter my Python interactive I get: The installations I ran previo…
Only add to a dict if a condition is met
I am using urllib.urlencode to build web POST parameters, however there are a few values I only want to be added if a value other than None exists for them. That works fine, however if I make the orange variable optional, how can I prevent it from being added to the parameters? Something like this (pseudocode…
Graph traversal with Networkx (Python)
I’m playing a bit with Networkx to manage a graph of dependencies. Let’s say I have this Graph which each letter represent a server So here we can see that before starting A we need to start H and B and to start H we need to start C and then to start B wee need to start C and