I'm on a fresh conda environment of Python 3.11.3. Using pip install patent_client works perfectly and install everything needed.
When running "import pantent_client" in python I get the following error:
No module named 'patent_client'
But whe running the same line in a Jupyter notebook I get:
IncompleteRead Traceback (most recent call last)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/urllib3/response.py:710, in HTTPResponse._error_catcher(self)
709 try:
--> 710 yield
712 except SocketTimeout as e:
713 # FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
714 # there is yet no clean way to get at it from this context.
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/urllib3/response.py:835, in HTTPResponse._raw_read(self, amt)
825 if (
826 self.enforce_content_length
827 and self.length_remaining is not None
(...)
833 # raised during streaming, so all calls with incorrect
834 # Content-Length are caught.
--> 835 raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
837 if data:
IncompleteRead: IncompleteRead(575718 bytes read, -287859 more expected)
The above exception was the direct cause of the following exception:
ProtocolError Traceback (most recent call last)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests/models.py:816, in Response.iter_content..generate()
815 try:
--> 816 yield from self.raw.stream(chunk_size, decode_content=True)
817 except ProtocolError as e:
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/urllib3/response.py:940, in HTTPResponse.stream(self, amt, decode_content)
939 while not is_fp_closed(self._fp) or len(self._decoded_buffer) > 0:
--> 940 data = self.read(amt=amt, decode_content=decode_content)
942 if data:
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/urllib3/response.py:911, in HTTPResponse.read(self, amt, decode_content, cache_content)
907 while len(self._decoded_buffer) < amt and data:
908 # TODO make sure to initially read enough data to get past the headers
909 # For example, the GZ file header takes 10 bytes, we don't want to read
910 # it one byte at a time
--> 911 data = self._raw_read(amt)
912 decoded_data = self._decode(data, decode_content, flush_decoder)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/urllib3/response.py:813, in HTTPResponse._raw_read(self, amt)
811 fp_closed = getattr(self._fp, "closed", False)
--> 813 with self._error_catcher():
814 data = self._fp_read(amt) if not fp_closed else b""
File ~/anaconda3/envs/me2drugs/lib/python3.11/contextlib.py:155, in _GeneratorContextManager.exit(self, typ, value, traceback)
154 try:
--> 155 self.gen.throw(typ, value, traceback)
156 except StopIteration as exc:
157 # Suppress StopIteration unless it's the same exception that
158 # was passed to throw(). This prevents a StopIteration
159 # raised inside the "with" statement from being suppressed.
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/urllib3/response.py:727, in HTTPResponse._error_catcher(self)
725 except (HTTPException, OSError) as e:
726 # This includes IncompleteRead.
--> 727 raise ProtocolError(f"Connection broken: {e!r}", e) from e
729 # If no exception is thrown, we should avoid cleaning up
730 # unnecessarily.
ProtocolError: ('Connection broken: IncompleteRead(575718 bytes read, -287859 more expected)', IncompleteRead(575718 bytes read, -287859 more expected))
During handling of the above exception, another exception occurred:
ChunkedEncodingError Traceback (most recent call last)
Cell In[21], line 1
----> 1 import patent_client
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/patent_client/init.py:51
46 import yankee
48 yankee.use_model = True
---> 51 from patent_client.epo.ops.published.model import Inpadoc # isort:skip
53 # from patent_client.usitc.model import ITCAttachment
54 # from patent_client.usitc.model import ITCDocument
55 # from patent_client.usitc.model import ITCInvestigation
56 from patent_client.uspto.assignment.model import Assignment # isort:skip
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/patent_client/epo/ops/init.py:2
1 from .family.model import Family
----> 2 from .legal.model import Legal
3 from .published.model import Images
4 from .published.model import Inpadoc
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/patent_client/epo/ops/legal/init.py:3
1 from .national_codes import generate_legal_code_db
----> 3 generate_legal_code_db()
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/patent_client/epo/ops/legal/national_codes.py:31, in generate_legal_code_db()
29 else:
30 logger.debug("Legal Code Database is out of date - creating legal code database")
---> 31 path = get_spreadsheet()
32 create_code_database(path)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/patent_client/epo/ops/legal/national_codes.py:62, in get_spreadsheet()
60 if out_path.exists():
61 return out_path
---> 62 response = session.get(excel_url, stream=True)
63 with out_path.open("wb") as f:
64 for chunk in response.iter_content(chunk_size=8192):
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests/sessions.py:602, in Session.get(self, url, **kwargs)
594 r"""Sends a GET request. Returns :class:Response
object.
595
596 :param url: URL for the new :class:Request
object.
597 :param **kwargs: Optional arguments that request
takes.
598 :rtype: requests.Response
599 """
601 kwargs.setdefault("allow_redirects", True)
--> 602 return self.request("GET", url, **kwargs)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/patent_client/epo/ops/session.py:34, in OpsSession.request(self, *args, **kwargs)
33 def request(self, *args, **kwargs):
---> 34 response = super(OpsSession, self).request(*args, **kwargs)
35 if response.status_code in (403, 400):
36 auth_response = self.get_token()
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests_cache/session.py:115, in CacheMixin.request(self, method, url, expire_after, *args, **kwargs)
112 kwargs['headers']['Cache-Control'] = f'max-age={get_expiration_seconds(expire_after)}'
114 with patch_form_boundary(**kwargs):
--> 115 return super().request(method, url, *args, **kwargs)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests/sessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
584 send_kwargs = {
585 "timeout": timeout,
586 "allow_redirects": allow_redirects,
587 }
588 send_kwargs.update(settings)
--> 589 resp = self.send(prep, **send_kwargs)
591 return resp
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests_cache/session.py:147, in CacheMixin.send(self, request, expire_after, **kwargs)
145 # If the response is expired or missing, or the cache is disabled, then fetch a new response
146 if cached_response is None:
--> 147 response = self._send_and_cache(request, actions, **kwargs)
148 elif is_expired and self.stale_if_error:
149 response = self._resend_and_ignore(request, actions, cached_response, **kwargs)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests_cache/session.py:193, in CacheMixin._send_and_cache(self, request, actions, cached_response, **kwargs)
190 actions.update_from_response(response)
192 if self._is_cacheable(response, actions):
--> 193 self.cache.save_response(response, actions.cache_key, actions.expires)
194 elif cached_response and response.status_code == 304:
195 return self._update_revalidated_response(actions, response, cached_response)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests_cache/backends/base.py:101, in BaseCache.save_response(self, response, cache_key, expires)
93 """Save a response to the cache
94
95 Args:
(...)
98 expires: Absolute expiration time for this response
99 """
100 cache_key = cache_key or self.create_key(response.request)
--> 101 cached_response = CachedResponse.from_response(response, expires=expires)
102 cached_response = redact_response(cached_response, self.ignored_parameters)
103 self.responses[cache_key] = cached_response
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests_cache/models/response.py:67, in CachedResponse.from_response(cls, original_response, expires, **kwargs)
65 # Store request, raw response, and next response (if it's a redirect response)
66 obj.request = CachedRequest.from_request(original_response.request)
---> 67 obj.raw = CachedHTTPResponse.from_response(original_response)
68 obj._next = (
69 CachedRequest.from_request(original_response.next) if original_response.next else None
70 )
72 # Store response body, which will have been read & decoded by requests.Response by now
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests_cache/models/raw_response.py:59, in CachedHTTPResponse.from_response(cls, original_response)
57 kwargs['body'] = body
58 raw._fp = BytesIO(body)
---> 59 original_response.content # This property reads, decodes, and stores response content
61 # After reading, reset file pointer on original raw response
62 raw._fp = BytesIO(body)
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests/models.py:899, in Response.content(self)
897 self._content = None
898 else:
--> 899 self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
901 self._content_consumed = True
902 # don't need to release the connection; that's been handled by urllib3
903 # since we exhausted the data.
File ~/anaconda3/envs/me2drugs/lib/python3.11/site-packages/requests/models.py:818, in Response.iter_content..generate()
816 yield from self.raw.stream(chunk_size, decode_content=True)
817 except ProtocolError as e:
--> 818 raise ChunkedEncodingError(e)
819 except DecodeError as e:
820 raise ContentDecodingError(e)
ChunkedEncodingError: ('Connection broken: IncompleteRead(575718 bytes read, -287859 more expected)', IncompleteRead(575718 bytes read, -287859 more expected))