Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tony

Pages: 1 ... 26 27 [28] 29 30 ... 40
406
Hi,

the config file is only ready after python has been initialized, therefore you need to have the PATH and PYTHONPATH environment variables (or registry entry in the case of the python path) set correctly regardless of what you put in the config file. Usually the python installer will do this for you.

When the config file is read the environment variables are updates, so any code run after python has started will see those environment variables. They are set before any of the python modules listed in the config are imported.

If the python dll could not be loaded that could be a problem other than the dll couldn't be found. If there are any dependencies that can't be loaded then that would cause that error. Using the python installer should set everything up correctly for you and is the easiest way to make sure everything can be loaded. Using depends.exe (www.dependencywalker.com) will show you what dependencies the python dll has.

Even if you don't have admin access you can still set user environment variables. You only need to be a local admin to set system environment variables usually. Alternatively you can use a batch script to launch Excel and set the environment variables in the script before launching excel. I would have thought that the simplest thing to do would be to have python installed on your PC for you by someone that does have local admin and then everything should 'just work'.

Best regards,
Tony

407
Hi,

oh that's interesting. I've not come across that problem before! I don't suppose it's a very common use-case but I'll take a look at that anyway. Thanks for letting me know.

cheers,
Tony

408
Help and Support / Re: Using xlcell for getting data
« on: December 14, 2013, 10:07:36 PM »
Hi,

you can't get an XLCell object, but you can use the Excel COM api and get a Range object that has a Value property.

Use pyxll.get_active_object to get the Excel application object (see automation.py example, xl_app function). The you can do something like app.ActiveSheet.Range("A1") to get the range you want. If you want to get the sheet the function is called with you can use pyxll.xlfCaller.

Best regards,
Tony

409
Help and Support / Re: Question about the thread_safe switch in pyxll
« on: December 14, 2013, 10:04:38 PM »
Hi Jack,

PyXLL uses the same python runtime as the normal CPython interpreter (in fact it even just uses the same dll). So, all the usual rules apply, an in this particular case the GIL is the reason you see the performance you do.

http://dabeaz.com/python/UnderstandingGIL.pdf

Excel will call your code from multiple real OS threads, but because of the GIL you don't see any benefit if only using plain python. To see any benefit you would be having to call some code that frees the GIL while it does something (eg IO code using the socket module or some cython or C code that explicitly releases the GIL).

Best regards,
Tony

410
Hi,

I don't see why you would be able to import win32com from your own module in Excel using pyxll but the automation example wouldn't work... but then I can't see the rest of the code in your module. If you look at the code for those example functions you'll see they're just checking whether the required modules can be imported.

Can you set the log level to DEBUG (in the pyxll.cfg file) and send me the complete log file from pyxll starting to those functions being evaluated (make sure you have recalculated them) and your module that does work please.

thanks,
Tony

411
Help and Support / Re: Problem with empy cells and numpy_array<float>
« on: December 03, 2013, 12:45:07 AM »
Yes, definitely when this change is made it will be in the c code and not in python. However, unless you're passing very large arrays between excel and python I can't imagine it would be so slow as to be much of a problem doing it all in python.

Best regards,
Tony

412
General Discussion / Re: RTD Functions
« on: December 03, 2013, 12:42:18 AM »
Hi,

I don't know of any reasons why that code wouldn't work in newer versions of Excel. I think I was using 2010 when I wrote it originally.

Do you have automatic re-calc turned on? If you had it set to manual calc then you would have to refresh by pressing F9, but otherwise it should tick automatically.

Best regards,
Tony

413
Help and Support / Re: Problem with empy cells and numpy_array<float>
« on: November 29, 2013, 12:04:54 AM »
Hi,

only actual errors get converted into NaNs currently, so yes that is the expected behaviour... but I can see that it would be more useful/intuitive if empty cells were also converted to NaN so I will make that change in the next release.

In the meantime you could use a custom type converter to handle this case for you, which might be better than dealing with it in the body of each function that's taking these arrays (see http://www.pyxll.com/docs/udfs.html#custom-types) and would be easier to remove once this change has been released.

Best regards,
Tony

414
Bugs and Suggestions / Re: 64-bit / 32 bit
« on: November 15, 2013, 10:31:14 AM »
Hi,

microsoft don't recommend 64 bit because not all third party addins haven't yet been made available as 64 bit - although now many have been so I would suggest you check the other addins you need and it may be possible to use 64 bit versions of everything.

If you want to mix 32 bit and 64 bit then it's perfectly possible to have both versions of python installed at the same time. There are plenty of python packages that support inter-process communication already so you could have a 32 bit pyxll addin that calls out to a 64 bit python process using any of those (e.g. multiprocessing, pyro, win32com - pyro or an out of process com server using win32com would suit what you're talking about very well). This will obviously not be as efficient as doing everything in process though.

Best regards,
Tony

415
Bugs and Suggestions / Re: Ribbon support
« on: November 15, 2013, 10:19:21 AM »
Hi,

no it doesn't at the moment. If you want to create a ribbon menu using python you can do it using win32com, though. There are a few examples on the web including this one http://markmail.org/download.xqy?id=5q3rh3wwi7hwopbx&number=1.

There's also some code in the forum (search for RTD and look for the function '_register') that shows how to register a python com addin when pyxll starts. Using that and win32com it shouldn't be too hard to add controls to the ribbon.

Thanks for the feedback. I'll look at this for a future release or maybe create a new example using win32com as described above.

Best regards,
Tony

416
Help and Support / Re: load python33.dll failed, error code 126
« on: November 06, 2013, 08:59:00 AM »
Hi Marcus,

you can't load a 64 bit dll in a 32 bit process, which is why python33.dll is failing to load. You need to either install 32 bit python, or 64 bit Excel and PyXLL.

Best regards,
Tony

417
Help and Support / Re: pyxll cell with macro formulas
« on: November 06, 2013, 12:15:55 AM »
Hi,

I've been looking at this and it actually is possible to get the sheet name from a non-macro function, just not the cell address. I've added a new property 'sheet_name' to XLCell that you can use to get the sheet name without having to make the function a macro function.

I've also added two new functions, xlSheetNm and xlSheetId which get the sheet name from an id and the id from the sheet name respectively. These wrap the Excel C API functions of the same names.

You can download a new version of PyXLL from the downloads page with these changes, just select the version '2.1.beta1' (the default is still 2.0.4).

Please let me know if you have any problems with this beta release.

Best regards,
Tony



418
Help and Support / Re: pyxll cell with macro formulas
« on: November 05, 2013, 07:03:23 PM »
Ok, I'll take a look at adding a function to do that and let you know.

Best regards,
Tony

419
Help and Support / Re: pyxll cell with macro formulas
« on: November 05, 2013, 05:40:37 PM »
Hi,

do you just need a function to get from a sheet_id to the sheet name later, when no longer inside the macro function? If so I can add a function to PyXLL that will do that - I don't think it's possible through the COM api.

Best regards,
Tony

420
Help and Support / Re: pyxll cell with macro formulas
« on: November 05, 2013, 10:42:30 AM »
Hi,

unfortunately any function taking an XLCell and also marked as a macro function will always be volatile. This is a limitation of the underlying Excel C API that PyXLL uses (see xlfRegister, http://msdn.microsoft.com/en-us/library/bb687900.aspx).

One thing you could try is taking out the expensive part of the function call and putting it in another function and cache the result using functools.lru_cache or something similar. lru_cache was only added in Python 3 but if you're using an earlier version you could use the code from here http://code.activestate.com/recipes/498245/.

You can't get the worksheet name without making the function a macro function, even from the sheet_id. The sheet id is an internal excel identifier and is the same as what would be returned by the Excel function xlSheetId (http://msdn.microsoft.com/en-us/library/office/bb687901.aspx). It is unique within a single instance of Excel across workbooks so you could use it as a dict key.

Best regards,
Tony

Pages: 1 ... 26 27 [28] 29 30 ... 40