tagged [python]

TypeError: worker() takes 0 positional arguments but 1 was given

TypeError: worker() takes 0 positional arguments but 1 was given I'm trying to implement a subclass and it throws the error: `TypeError: worker() takes 0 positional arguments but 1 was given` ``` clas...

19 Sep at 01:23

Unzipping files in Python

Unzipping files in Python I read through the [zipfile documentation](https://docs.python.org/3/library/zipfile.html), but couldn't understand how to a file, only how to zip a file. How do I unzip all ...

1 May at 12:27

What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?

What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python? When I try to use a `print` statement in Python, it gives me this error: What does that mean?

5 Jun at 16:27

python mpl_toolkits installation issue

python mpl_toolkits installation issue After command `pip install mpl_toolkits` I receive next error: > Could not find a version that satisfies the requirement mpl_toolkits (from versions: )No matchin...

28 Dec at 02:24

TypeError: 'module' object is not callable

TypeError: 'module' object is not callable Why am I getting this error? I'm confused. How can I solve this error?

I can't install python-ldap

I can't install python-ldap When I run the following command: I get this error: > In file included from Modules/LDAPObject.c:9:Modules/errors.h:8: fatal error: lber.h: No such file or directory Any id...

21 Jul at 14:17

What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?

What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc? Python 3.3 includes in its standard library the new package `venv`. What does it do, and how does it dif...

How to upgrade Python version to 3.7?

How to upgrade Python version to 3.7? I have python3.5 already in linux ubuntu. I have downloaded the python3.7.tar [www.python.org](http://www.python.org). But i have no idea how to install it. How t...

11 Jul at 07:40

How to avoid "Permission denied" when using pip with virtualenv

How to avoid "Permission denied" when using pip with virtualenv I attempt to deploy a Python package with `pip` in a virtual environment on an Ubuntu machine, but encounter a permission-related issue....

How can I use threading in Python?

How can I use threading in Python? I am trying to understand threading in Python. I've looked at the documentation and examples, but quite frankly, many examples are overly sophisticated and I'm havin...

Importing files from different folder

Importing files from different folder I have this folder structure: How can I import a function from `file.py`, from within `some_file.py`? I tried: but it doesn't work.

28 Aug at 02:26

Explain the "setUp" and "tearDown" Python methods used in test cases

Explain the "setUp" and "tearDown" Python methods used in test cases Can anyone explain the use of Python's `setUp` and `tearDown` methods while writing test cases apart from that `setUp` is called im...

20 Feb at 11:43

Convert string to variable name in python

Convert string to variable name in python I have any string. like 'buffalo', I want to convert this string to some variable name like, not only this example, I want to convert any input string to some...

20 Feb at 15:8

How to write PNG image to string with the PIL?

How to write PNG image to string with the PIL? I have generated an image using [PIL](http://www.pythonware.com/products/pil/). How can I save it to a string in memory? The `Image.save()` method requir...

29 May at 16:30

How to load a C# dll in python?

How to load a C# dll in python? how can I load a c# dll in python? Do I have to put some extra code in the c# files? (like export in c++ files) I don't want to use IronPython. I want to import a modul...

7 Sep at 20:27

Get exception description and stack trace which caused an exception, all as a string

Get exception description and stack trace which caused an exception, all as a string How to convert a caught `Exception` (its description and stack trace) into a `str` for external use?

How to print variables without spaces between values

How to print variables without spaces between values I would like to know how to remove additional spaces when I print something. Like when I do: The output will be: But I want: Is there any way to do...

23 Feb at 09:45

How would I stop a while loop after n amount of time?

How would I stop a while loop after n amount of time? how would I stop a while loop after 5 minutes if it does not achieve what I want it to achieve. This code throws me in an endless loop.

23 Mar at 20:15

Difference between os.getenv and os.environ.get

Difference between os.getenv and os.environ.get Is there any difference at all between both approaches? They seem to have the exact same functionality.

How to sort a dataFrame in python pandas by two or more columns?

How to sort a dataFrame in python pandas by two or more columns? Suppose I have a dataframe with columns `a`, `b` and `c`, I want to sort the dataframe by column `b` in ascending order, and by column ...

How do I create test and train samples from one dataframe with pandas?

How do I create test and train samples from one dataframe with pandas? I have a fairly large dataset in the form of a dataframe and I was wondering how I would be able to split the dataframe into two ...

10 Jun at 17:24

What is the best way to remove accents (normalize) in a Python unicode string?

What is the best way to remove accents (normalize) in a Python unicode string? I have a Unicode string in Python, and I would like to remove all the accents (diacritics). I found on the web an elegant...

EOFError: EOF when reading a line

EOFError: EOF when reading a line I am trying to define a function to make the perimeter of a rectangle. Here is the code: I think I haven't left any arguments opened or anything like that.

16 Jul at 11:56

Extract Number from String in Python

Extract Number from String in Python I am new to `Python` and I have a String, I want to extract the numbers from the string. For example: Output is `['4', '3']` I want to get `3158` only, as an Integ...

2 Nov at 18:11

pip install returning invalid syntax

pip install returning invalid syntax I've just installed python 3.6 which comes with pip However, in Windows command prompt, when I do: 'pip install bs4' it returns 'SyntaxError: invalid syntax' under...

4 Dec at 12:11