cmallwitz / Financials-Extension

Extension for LibreOffice Calc to access stock market data
Other
137 stars 17 forks source link

macos: upgraded python now getting error: urlopen: argument must be an int #41

Closed gb13717 closed 2 years ago

gb13717 commented 2 years ago

I recently uninstalled/reinstalled python 3. Now I'm getting an error this is what I put in a cell: =GETREALTIME("BTC-USD",21,"YAHOO")

this is what the cell shows: Yahoo.getRealtime(BTC-USD,21) - urlopen: argument must be an int, or have a fileno() method.

But I dont get this error when I open this spreadsheet on my linux box so its gotta be something messed on in python?

cmallwitz commented 2 years ago

Two things to look for:

1) in your user home directory the should be a directory .financials-extension with file extension.log - does this contain anything more?

2) On Windows LibreOffice ships with its own Python packages so I wouldn't expect you to mess with it by uninstalling/reinstalling Python separately. Having said that maybe if this ends in your %PATH% variable before LO there could be some unforeseen side effects. From the Windows start button, could you launch a "Command Prompt" (CMD window) and run "python --version" to see what you get. Alternatively maybe just "python" and then

import sys sys.path

Lets see if we can spot any mix ups...

cmallwitz commented 2 years ago

And you could take a look at the output from =GETREALTIME("SUPPORT")

This will contain sys.path from the LO / extension perspective.

gb13717 commented 2 years ago

I'm on MacOS

extension.log has a ton of errors that are all similar to this one: 2021-10-31 12:05:56,883 financials_yahoo ERROR BaseException ticker=MATIC-USD datacode=21 Traceback (most recent call last): File "/Users/xxx/Library/Application Support/LibreOffice/4/user/uno_packages/cache/uno_packages/lu6962744da5e.tmp_/Financials-Extension-2.oxt/financials_yahoo.py", line 129, in getRealtime text = self.urlopen(url, redirect=True, data=None, headers=None, cookies=cookies) File "/Users/xxx/Library/Application Support/LibreOffice/4/user/uno_packages/cache/uno_packages/lu6962744da5e.tmp_/Financials-Extension-2.oxt/baseclient.py", line 142, in urlopen self.response = self.request('POST' if data else 'GET', url, data, headers, cookies, **kwargs) File "/Users/xxx/Library/Application Support/LibreOffice/4/user/uno_packages/cache/uno_packages/lu6962744da5e.tmp_/Financials-Extension-2.oxt/baseclient.py", line 102, in request if connection and select.select([connection.sock], [], [], 0)[0]: TypeError: argument must be an int, or have a fileno() method.

python --version returns Python 2.7.16 which I read is the version that comes with macos

python3 --version returns Python 3.10.0 which is what I installed

GETREALTIME("SUPPORT") returns ctx=pyuno object (com.sun.star.uno.XComponentContext)0x600000cd99f0{, supportedInterfaces={com.sun.star.uno.XComponentContext,com.sun.star.container.XNameContainer,com.sun.star.lang.XTypeProvider,com.sun.star.uno.XWeak,com.sun.star.lang.XComponent}} id(self)=5927214864 version=3.0.4 file=/Users/xxx/Library/Application Support/LibreOffice/4/user/uno_packages/cache/uno_packages/lu6962744da5e.tmp_/Financials-Extension-2.oxt/financials.py cwd=/ home=/Users/xxx uname=Darwin MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:20 PDT 2021; root:xnu-7195.141.6~3/RELEASE_ARM64_T8101 x86_64 i386 pid=26911 sys.executable=/Applications/LibreOffice.app/Contents/MacOS/soffice sys.version=3.8.8rc1 (default, Jul 17 2021, 21:07:21) [Clang 11.0.0 (clang-1100.0.33.17)] sys.path=['/Users/xxx/Library/Application Support/LibreOffice/4/user/uno_packages/cache/uno_packages/lu6962744da5e.tmp_/Financials-Extension-2.oxt', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/Current/lib/python3.8', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/Current/lib/python3.8/lib-dynload', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/Current/lib/python3.8/lib-tk', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/Current/lib/python3.8/site-packages', '/Applications/LibreOffice.app/Contents/Resources', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python38.zip', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.8', '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.8/lib-dynload', '/Applications/LibreOffice.app/Contents/Resources/extensions/dict-en/pythonpath'] locale=(None, None) defaultlocale=('en_US', 'UTF-8') dateutil=2.8.1 pytz=2021.1 pyparsing=2.4.7 six=1.15.0

cmallwitz commented 2 years ago

Sorry for not coming back earlier.

I can't see any trace of a python installation installed separately from LO in those paths so would assume it doesn't interfere.

How about re-installing LO ?

gb13717 commented 2 years ago

Hi - Not sure how/why, but it starting working again thanks!