tomquirk / linkedin-api

👨‍💼Linkedin API for Python
MIT License
1.78k stars 408 forks source link

read only error when deploying in Google Cloud Functions #245

Open jason79 opened 2 years ago

jason79 commented 2 years ago

I have some simple code I'm trying out in Google cloud functions using your API. It's telling me "Read-only file system". Can the code be modified to run in Google Cloud Functions?

Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/layers/google.python.pip/pip/lib/python3.10/site-packages/functions_framework/__init__.py", line 99, in view_func return function(request._get_current_object()) File "/workspace/main.py", line 5, in entry api = Linkedin('xxxxx@gmail.com', 'xxxxxx') File "/layers/google.python.pip/pip/lib/python3.10/site-packages/linkedin_api/linkedin.py", line 37, in __init__ self.client.authenticate(username, password) File "/layers/google.python.pip/pip/lib/python3.10/site-packages/linkedin_api/client.py", line 98, in authenticate self._set_session_cookies(self._request_session_cookies()) File "/layers/google.python.pip/pip/lib/python3.10/site-packages/linkedin_api/client.py", line 89, in _set_session_cookies with open(settings.COOKIE_FILE_PATH, "wb") as f: OSError: [Errno 30] Read-only file system: '/layers/google.python.pip/pip/lib/python3.10/site-packages/linkedin_api/.cookie.jr'

tbressers commented 2 years ago

Try to set the cookie directory to a location which is readable and writable

jason79 commented 2 years ago

how do you do that? can you show me some code?

tbressers commented 2 years ago

I’d start looking for file names with “cookies” in them or related to cookie handling. And then look for code where those cookie functions are used and then apply it in your own code.

Does that work for you?

Rgds Thijs

Op ma 25 jul. 2022 om 00:18 schreef jason79 @.***>

how do you do that? can you show me some code?

— Reply to this email directly, view it on GitHub https://github.com/tomquirk/linkedin-api/issues/245#issuecomment-1193404783, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB5RUVDUPRP7ELARY7YXQ3VVW6NBANCNFSM54QFNNKQ . You are receiving this because you commented.Message ID: @.***>

jason79 commented 2 years ago

I guess i can't do it.... because I can't change the code in the cloud. Google Cloud Functions is pulling the library in through the requirements file. Does that make sense?

tangsaidi commented 1 year ago
Linkedin(linkedin_user, linkedin_pass, cookies_dir='/tmp/cookies')

should do