A federal judge in Philadelphia has barred Bill Cosby from attending the deposition his accuser gives in her defamation suit against a former district attorney.