Author Topic: Anaconda Root Env=2.7; Virtual Env=3.4 + Pyxll3.4?  (Read 591 times)


  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Anaconda Root Env=2.7; Virtual Env=3.4 + Pyxll3.4?
« on: April 10, 2015, 07:29:02 PM »
I use Anaconda. Root environment is using Python 2.7 (for some reasons that I cannot control). I have a virtual environment that uses Python 3.4, Can I set up Pyxll for 3.4? Thanks a lot


  • Administrator
  • Hero Member
  • *****
  • Posts: 638
  • Karma: +15/-1
    • View Profile
Re: Anaconda Root Env=2.7; Virtual Env=3.4 + Pyxll3.4?
« Reply #1 on: April 13, 2015, 10:24:19 AM »

usually I'd recommend installing the Python you want to use so it's on the PATH and the PYTHONPATH is set correctly, but I understand in your case that is not possible.

It will still be possible to make it work, and you have a couple of options.

Possibly the easier option would be to open a command prompt and activate the virtualenv using the active.bat script in the Scripts folder of the virtualenv. Then, from the same command prompt start Excel. You can find where the EXCEL.EXE binary has been installed by looking at the properties of the Excel shortcut in your start menu. Assuming that works correctly, you could put that into a .bat file and use that every time you start Excel instead of your usual Excel shortcut.

The second option is to put the python dll from your virtualenv in the same folder as pyxll.xll (or alternatively put pyxll.xll in the virtualenv in the same folder as the python dll). PyXLL will look in the same folder it's in for the python dll before searching on the PATH. Once it finds the python dll, however, it needs to know what to use for the PYTHONPATH. The easiest way to set that is as an environment variable - but, if that's not possible then there's another way to do it...

Create a file called "" in the same folder as the pyxll.xll file. That will be imported before anything else (including when PyXLL starts, and you can use this to set the pythonpath programmatically with something like this:

Code: [Select]
import sys
sys.path.extend(["C:\myvirtualenv\lib", "C:\myvirtualenv\DLLs", "C:\myvirtualenv\lib\site-packages", ...etc...])

You can check what the python path should be by printing sys.path from a normal python prompt using your virtualenv.

One thing that might help is setting the PYXLL_DEBUG_LOG environment variable (eg set PYXLL_DEBUG_LOG=c:/temp/pyxll-debug.log). You can do that from a command prompt and start Excel from the same command prompt if you can't set it globally. This will print out more information about what's happening while PyXLL is attempting to start Python and so will help you check the right dll is being used and how the python path is being set.

One other thing to be aware of is that if you have added PyXLL to Excel from another location, Excel will remember this even if you disable the addin. To be sure the correct version is being loaded you should delete all other copies of the xll. Alternatively, you can use the uninstall script from github ( This will remove all references of PyXLL from Excel.

I hope this helps. Please let me know if you are unable to get it working or need any more help.

Best regards,