Since Slicer bundles its own python, it is generally NOT possible to simply copy python packages (especially the one including binaries) from your own site-packages into the one of Slicer.
That said, depending on the platform there is way around it.
First, I suggest you download the latest nightly build of Slicer.
There are a lot of improvement regarding the python infrastructure. It for example includes an updated setuptools as well as pip.
Second, on linux (and most likely macOS), it is indeed possible to pip install official packages (even the including binaries like scipy, tensorflow, …).
On windows, it will currently work only for pure python wheels because the official package for python 2.7 are built with a compiler than the one used for the official wheels. Note that this will change as soon as we standardize on Visual Studio 2015 and switch to python >= 3.5.
As mentioned above, the good news is that pip is available in Slicer.
I tried this
Slicer.exe --launch …\python-install\bin\pip.exe install name-of-pure-python-wheel
Seems like Slicer started to load, but then nothing happened.
Also, is the python-install/bin folder supposed to be inside the Slicer directory? I am not able to find it nor the pip.exe
Thanks so much!
While the installation worked well for some packages (e.g. PIL and matplotlib wheels), it still doesn’t work for “scipy”, “sckimage”, etc. Does anyone know what happened? Thank you!
I did uninstall numpy and installed numpy+mkl since scipy complained numpy didn’t have mkl.
In particular, I get the following error,
path=r"C:\Program Files\Slicer 4.7.0-2017-09-05\packages\scipy-0.19.1-cp27-cp27m-win_amd64.whl"
Processing c:\program files\slicer 4.7.0-2017-09-05\packages\scipy-0.19.1-cp27-cp27m-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in c:\program files\slicer 4.7.0-2017-09-05\lib\python\lib\site-packages\numpy-1.13.1-py2.7-win-amd64.egg (from scipy==0.19.1)
Traceback (most recent call last):
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\basecommand_.py", line 215, in main
status = self.run(options, args)
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\commands\install_.py", line 335, in run
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\wheel_.py", line 749, in build
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\req\req_set.py", line 666, in _prepare_file
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\utils\packaging_.py", line 48, in check_dist_requires_python
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\email\feedparser_.py", line 177, in feed
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\email\feedparser_.py", line 99, in push
parts = data.splitlines(True)
AttributeError: 'NoneType' object has no attribute 'splitlines'
a quick questions concerning this topic. I am developing with Slicer on Windows and was also trying to install a module with precompiled data, namely pywin32. After some try and error I figured out that pywin32 also uses precompiled data. Since Slicers Python is build with VS2013 but the module has precompiled with VS2008 I assume the runtimes collide here.
My plan was now to build Slicer on my own such that I also have a Python.exe build with VS2013. Afterwards I would go to pywin32 gitlab page and build the module manually as well. Building pywin32 requires the Python.exe file, thats why I need to build Slicer as well.
If you build Slicer according to build instructions and you build the Python package using the same compiler and compiler settings then it should all work. If you need a Python.exe, you can use Slicer’s SlicerPython.exe.
Note that Slicer includes Qt library, which provides access to lots of Windows APIs (and Linux and macOS APIs), so you might be able to do without pywin32.
If the API is not available in Qt, or you need code to work outside the Slicer environment too, then you could also try pywincffi. That uses the CFFI module, which can construct calls at runtime via ctypes/libffi (in CPython), and avoid the need for dealing with compiled shim libraries.
WHy pip.main not working for me. I run as administrator even then its not working for me
Python 2.7.13 (default, Aug 31 2018, 23:24:30) [MSC v.1900 64 bit (AMD64)] on win32
AttributeError: ‘module’ object has no attribute ‘main’
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘c:\users\22374464\appdata\local\temp\pip-req-tracker-v9vnky\6fa5e984c9f7c4180f5cbc9dc5bc4378cf0a090dcb740963746419f9’