Error trying to install backports: "No matching distribution found for backports"

1

I'm trying to use backports testing the code given by Sachin Joglekar in a project on convolutional neural networks for a project to classify toxic comments .

from backports import csv

but when I try to load it with python2.7 or python3 I have errors:

With python3 I have the following:

mike@mike-thinks:~/Kaggle$ sudo pip install backports.weakref
The directory '/home/mike/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mike/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: backports.weakref in /usr/local/lib/python2.7/dist-packages

mike@mike-thinks:~/Kaggle$ sudo pip install backports
The directory '/home/mike/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mike/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting backports
  Could not find a version that satisfies the requirement backports (from versions: )
No matching distribution found for backports

With python2.7:

mike@mike-thinks:~/Kaggle$ python medium.py 
Traceback (most recent call last):
  File "medium.py", line 1, in <module>
    from backports import csv
ImportError: cannot import name csv
    
asked by ThePassenger 11.03.2018 в 11:15
source

1 answer

1

In PyPI backports is not really a package that contains all existing backports , it only exists to reserve the namespace backports for packages with these purposes.

I suppose you want to use the Python 3 csv module in Python 2 through its backport . In this case you must install the module backports.csv in Python 2:

sudo pip install backports.csv

This supposes that your default interpreter is Python 2.7 as it is deduced from what the console shows you. Remember to use pip3 install to install modules in Python 3.x. Personally I prefer to install via python3 -m pip intall... / python2.7 -m pip install... / <Ruta a interprete cualquiera con pip instalado> -m pip install... / etc, it is more explicit.

  

Note: It is not recommended to install libraries directly on the OS Python installation via sudo. It is always better to use a virtual environment for these purposes and install in the packages keeping the installation of the system clean and safe.

    
answered by 11.03.2018 / 11:56
source