Python (pip) - RequestsDependencyWarning: urllib3 (1.9.1) or chardet (2.3.0) doesn't match a supported version
You do have a mixed setup (both apt
and pip
were used to install system-wide, which is common), and it indeed doesn't match the supported versions of modules required by requests (and pip v1.5.6 is also quite old).
The requests
(which version? likely leftover from pip install
) requires:
urllib3: 1.21.1 - 1.22
chardet: 3.0.2 - 3.1.0
You have:
urllib3 (1.9.1) from python-urllib3 1.9.1-3 debian package
chardet (2.3.0) from python-chardet 2.3.0-1 debian package
Two options:
either downgrade
requests
to the version from your OS distribution (see what's available withapt show python-requests
), or older versions at pypi.org, oror install newer urllib3 and chardet (you can download the wheel files manually from pipy.org and do
pip install
on them, including any dependencies), either at user level (--user
pip install option) or in a virtualenv.
You can test everything in a virtualenv (apt show python-virtualenv
). It should even deploy a newer pip for you inside of its virtual envs. It is also possible to install a newer pip 10.0.1 at the user-level (--user
) alongside your OS-vendored pip but you need to be careful about that. Good luck!
Subclasses and return types
Your first solution is pretty good, IMHO. But let's talk about the questions. First, about what is wrong here:
abstract class PDF[T] {
def fit[S <: PDF[T]](obs: Seq[T], weights: Seq[Double]): S
}
class PDFGaussian(val mu: Double, val Sigma: Double) extends PDF[Double] {
def fit[S <: PDF[_]](obs: Seq[Double], weights: Seq[Double]): S =
new PDFGaussian(...) // bla bla bla
}
Let's say I have
class FooBar extends PDF[Double] { ... }
And I do:
val pdfg = new PDFGaussian(1.0, -1.0)
val foobar = pdfg.fit[FooBar](List(0.5, 0.75), List(4, 2))
So, I'm telling the compiler that I want S
to be FooBar
, but you are returning PDFGaussian
! That's what the compiler is complaining about.
So, how to solve it? Well... tough. :-) How about this:
abstract class PDF[T] {
type S <: PDF[T]
def fit(obs: Seq[T], weights: Seq[Double]): S
}
class PDFGaussian(val mu: Double, val Sigma: Double) extends PDF[Double] {
type S = PDFGaussian
def fit(obs: Seq[Double], weights: Seq[Double]): S =
new PDFGaussian(...) // bla bla bla
}
It's a bit more verbose, but it keeps PDF
type signature cleaner.
Related Topics
How to Join Multiple Txt Files into Based on Column
Cron Job Mysteriously Stopped Running
Laravel-Mix No Build Notification
Overview/Reference Manual for Open Firmware Device Trees
Understanding Glibc Malloc Trimming
How to Get Notified of Modification in The Memory in Linux
How to Check That Smart Card Is Working on Linux
Find Ip Address of My System for a Particular Interface with Shell Script (Bash)
Echo 'The Character - (Dash) in The Unix Command Line
Can You Explain This Sed One-Liner
Get Man Pages for Driver Functions
Statically Linked Shared Object? or a Corrupt File
Unshare User Namespace and Set UId Mapping with Newuidmap
Linux >2.6.33: Could Sendfile() Be Used to Implement a Faster 'Cat'
How Make /Var/Www Contents Editable by Ide