You can do a law conversion course (GDL) after any degree.To become a barrister you would need to do the GDL, but it would not be a barrier to going that route.
You can become a solicitor without doing the GDL potentially as you just need to sit the SQE, although in practice you may find it hard or impossible to pass the SQE without doing the GDL or a prep course covering similar content, if your first degree is a non-law degree, as I understand it.