The prohibition against degeneracy of the energy levels in one-dimension is given in standard textbooks.1
Assume that there are two solutions $\psi_{a}$ and $\psi_{b}$ that have the same energy $E$. Each will satsify the Time-Independent Schrodinger equation as follows
\[ -\frac{\hbar^2}{2m} \frac{d^2 \psi_{a}}{dx^2} + V(x)\psi_{a} = E\psi_{a} \tag{1} \label{Eq:1} \]
\[ -\frac{\hbar^2}{2m} \frac{d^2 \psi_{b}}{dx^2} + V(x)\psi_{b} = E\psi_{b} \tag{2} \label{Eq:2} \]
Multiplying Eq.\eqref{Eq:1} by $\psi_{b}$ and multiplying Eq.\eqref{Eq:2} by $\psi_{a}$ results in
\[ -\frac{\hbar^2}{2m}\Big ( \frac{d^2 \psi_{a}}{dx^2} \Big ) \psi_{b} + V(x)\psi_{a} \psi_{b} = E\psi_{a} \psi_{b} \tag{3} \label{Eq:3} \]
\[ -\frac{\hbar^2}{2m} \Big (\frac{d^2 \psi_{b}}{dx^2} \Big ) \psi_{a} + V(x)\psi_{b} \psi_{a} = E\psi_{b} \psi_{a} \tag{4} \label{Eq:4} \]
Subtracting Eq.\eqref{Eq:4} from Eq.\eqref{Eq:3} yields
\[ -\frac{\hbar^2}{2m}\Big [ \Big ( \frac{d^2 \psi_{a}}{dx^2} \Big ) \psi_{b} – \Big (\frac{d^2 \psi_{b}}{dx^2} \Big ) \psi_{a} \Big ] = 0 \tag{5} \label{Eq:5} \]
Equation \eqref{Eq:5} can be rewritten as
\[ -\frac{\hbar^2}{2m} \cdot \frac{d}{dx} \Big [ \psi_{b} \Big ( \frac{d\psi_{a}}{dx} \Big ) – \psi_{a} \Big (\frac{d\psi_{b}}{dx} \Big ) \Big ] = 0 \notag \]
Which implies that
\[ \psi_{b} \Big ( \frac{d\psi_{a}}{dx} \Big ) – \psi_{a} \Big (\frac{d\psi_{b}}{dx} \Big ) = C \qquad C =\text{constant} \tag{6} \label{Eq:6} \]
Since this relationship holds true at any point $x$, then taking the standard assumption that
\[ \lim\limits_{x \to \pm \infty} \psi_{a}(x) = 0 \notag \]
\[ \text{and} \notag \]
\[ \lim\limits_{x \to \pm \infty} \psi_{b}(x) = 0 \notag \]
results in $C=0$ which should be constant for $ -\infty < x <+ \infty$.
Setting $C=0$, rearranging Eq.\eqref{Eq:6} gives the following relationship
\[ \frac{1}{\psi_{a}} \Big(\frac{d \psi_{a}}{dx} \Big ) = \frac{1}{\psi_{b}}\Big(\frac{d \psi_{b}}{dx} \Big ) \tag{7} \label{Eq:7} \]
resulting in
\[ \text{ln} (\psi_{a}) =\text{ ln} (\psi_{b}) + c \qquad c=\text{constant} \notag \]
as the relationship between $\psi_{a}$ and $\psi_{b}$. Expressing the relationship in exponential form gives
\[ \psi_{a} = e^{c} \psi_{b} \notag \]
showing that $\psi_{a}$ and $\psi_{b}$ are not linearly independent functions.
Note that in order to proceed from Eq.\eqref{Eq:6} to Eq.\eqref{Eq:7}, it is assumed that the first derivative is continuous everywhere.
For the particle in an infinite well, the assumption of continuity of the first derivative $d\psi/dx$ is false. Even in the traditional approach in which the value of the wave function $\psi$ is equated with zero at the boundary, it is accepted that the first derivative $d \psi/dx$ is not continuous at the boundary. Therefore, for the particle in a box, the prohibition against degeneracy is not applicable.