Using the python installed in system for Slicer

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Using the python installed in system for Slicer

amit12690
Hi all,
I have a version of scientific python installed in my machine. But Slicer uses its own version of python.
Is there any way I can make slicer work with the python installed in my system ? I need to do this because I have written some modules which I need to import in slicer but it is not possible presently because the slicer based python does not support many libraries like scipy , matplotlib etc.  

Thanks a lot,
Amit
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

Steve Pieper-2
Hi Amit -

A lot depends on the specific packages and builds involved, but if you use a python 2.7 build (something like EPD or anaconda) you can probably just append to sys.path and import most things.  This [1] shows doing it in slicer3.  Note though that if the python code includes C or C++ dependencies you can get version clashes.

Another option is to build slicer against your locally installed python by pointing cmake to the python install.  This should be doable but is not something we've really explored and documented.

-Steve

[1] http://www.slicer.org/slicerWiki/index.php/Slicer3:Python#Using_System_Python_Libraries_with_Slicer.27s_python


On Wed, Aug 6, 2014 at 8:06 AM, amit12690 <[hidden email]> wrote:
Hi all,
I have a version of scientific python installed in my machine. But Slicer
uses its own version of python.
Is there any way I can make slicer work with the python installed in my
system ? I need to do this because I have written some modules which I need
to import in slicer but it is not possible presently because the slicer
based python does not support many libraries like scipy , matplotlib etc.

Thanks a lot,
Amit



--
View this message in context: http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

amit12690
Hi Steve,
Thanks a lot for the information. I am using Slicer version 4. So any information on using external python for it ??

with regards,
Amit 


On Wed, Aug 6, 2014 at 5:55 PM, Steve Pieper-2 [via slicer-users] <[hidden email]> wrote:
Hi Amit -

A lot depends on the specific packages and builds involved, but if you use a python 2.7 build (something like EPD or anaconda) you can probably just append to sys.path and import most things.  This [1] shows doing it in slicer3.  Note though that if the python code includes C or C++ dependencies you can get version clashes.

Another option is to build slicer against your locally installed python by pointing cmake to the python install.  This should be doable but is not something we've really explored and documented.

-Steve

[1] http://www.slicer.org/slicerWiki/index.php/Slicer3:Python#Using_System_Python_Libraries_with_Slicer.27s_python


On Wed, Aug 6, 2014 at 8:06 AM, amit12690 <[hidden email]> wrote:
Hi all,
I have a version of scientific python installed in my machine. But Slicer
uses its own version of python.
Is there any way I can make slicer work with the python installed in my
system ? I need to do this because I have written some modules which I need
to import in slicer but it is not possible presently because the slicer
based python does not support many libraries like scipy , matplotlib etc.

Thanks a lot,
Amit



--
View this message in context: http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject

http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



If you reply to this email, your message will be added to the discussion below:
http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921p4027922.html
To unsubscribe from Using the python installed in system for Slicer, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

Steve Pieper-2
Hi Amit - 

Yes, that's what I meant - the same approach should work for slicer4 - you append to the sys.path list.

-Steve


On Wed, Aug 6, 2014 at 11:56 AM, amit12690 <[hidden email]> wrote:
Hi Steve,
Thanks a lot for the information. I am using Slicer version 4. So any information on using external python for it ??

with regards,
Amit 


On Wed, Aug 6, 2014 at 5:55 PM, Steve Pieper-2 [via slicer-users] <[hidden email]> wrote:
Hi Amit -

A lot depends on the specific packages and builds involved, but if you use a python 2.7 build (something like EPD or anaconda) you can probably just append to sys.path and import most things.  This [1] shows doing it in slicer3.  Note though that if the python code includes C or C++ dependencies you can get version clashes.

Another option is to build slicer against your locally installed python by pointing cmake to the python install.  This should be doable but is not something we've really explored and documented.

-Steve

[1] http://www.slicer.org/slicerWiki/index.php/Slicer3:Python#Using_System_Python_Libraries_with_Slicer.27s_python


On Wed, Aug 6, 2014 at 8:06 AM, amit12690 <[hidden email]> wrote:
Hi all,
I have a version of scientific python installed in my machine. But Slicer
uses its own version of python.
Is there any way I can make slicer work with the python installed in my
system ? I need to do this because I have written some modules which I need
to import in slicer but it is not possible presently because the slicer
based python does not support many libraries like scipy , matplotlib etc.

Thanks a lot,
Amit



--
View this message in context: http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject

http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



If you reply to this email, your message will be added to the discussion below:
http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921p4027922.html
To unsubscribe from Using the python installed in system for Slicer, click here.
NAML



View this message in context: Re: Using the python installed in system for Slicer

Sent from the slicer-users mailing list archive at Nabble.com.

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

amit12690
I tried that but somehow it is not resetting the path to slicer's original path once I restart slicer. Is there any possibility of downloading and installing scipy kind of modules in to slicer's python ?
Also can openCV  be integrated with slicer-python by any chance?

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

Steve Pieper-2


On Thu, Aug 7, 2014 at 8:31 AM, amit12690 <[hidden email]> wrote:
I tried that but somehow it is not resetting the path to slicer's original
path once I restart slicer. Is there any possibility of downloading and
installing scipy kind of modules in to slicer's python ?
Also can openCV  be integrated with slicer-python by any chance?

Thank you



--
View this message in context: http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921p4027930.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

amit12690
Hi Steve ,
Thanks a lot for your support. I have some confusions left . Let me state my situation and I think then it will be easier to understand.
1.) I have a python2.7 already installed in my system . All the packages linked to it are present in "/usr/local/lib/python2.7/dist-packages/".. It has almost all scientific packages.

2.) Now I installed Slicer3D ver 4.3.1_linux_amd-64. Slicer also has a python2.7.
I went inside the Python module in the Slicer folder . The path is as follows : "/home/usr1/Downloads/Slicer-4.3.1-linux-amd64/lib/Python//lib/python2.7/ ". Here I didn't  find any folder called "dist-packages" as highlighted in point 1 , I could only find "site-packages".
So I downloaded scipy.tar.gz file extracted it in "/home/usr1/Downloads/Slicer-4.3.1-linux-amd64/lib/Python//lib/python2.7/ site-packages" and did a python setup.py in the same folder.

The scipy setup failed with error : "error: could not create '/usr/local/lib/python2.7/dist-packages/scipy': Permission denied" 

I feel this is failing because the setup detects the system installed python and not slicer's python.

3.) I went through the link for installing external packages :  http://www.na-mic.org/Wiki/index.php/2013_Project_Week_Breakout_Session:Slicer4Python#Working_with_python_modules_that_are_not_bundled_with_slicer.27s_binary_distribution 
But they have only provided example for MAC OS and not linux.

4.) So now I come to my understanding . I feel that I cant install packages like scipy , scikit etc for Slicer-python because I already have them installed for system python .
So the only alternative left is to make Slicer work with the packages installed for system installed python but I dont have any idea how to achieve that.

I referred the following link on slicer ver.3 :http://www.slicer.org/slicerWiki/index.php/Slicer3:Python#Using_System_Python_Libraries_with_Slicer.27s_python 
But using sys.path.append('/usr/lib/python2.7/dist-packages/scipy') did not work for me. Instead it gave some errors which I have attached as a txt file with this post.

Sorry for such a long post . I just wanted to put everything in a clear way .
It will really be of great help to me out if anyone could  let me know how I should go about with the process of installing Slicer and if there are any ways to set system python path to slicer4 effectively . please do let me know if any more details are needed . I would also love to contribute for Slicer3D as well.

Thank you

error_while_using_scipy.txt

Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

kmader
In reply to this post by Steve Pieper-2


Steve Pieper-2 wrote
>>> Another option is to build slicer against your locally installed python
>>> by pointing cmake to the python install.  This should be doable but is
>>> not
>>> something we've really explored and documented.
>>>
>>> -Steve

Has anyone tried this for Anaconda? I would like to have 3d slicer as a
package in an existing python environment so that I could simply call
functionality from 3D slicer within a web-based python tool. Clearly I will
have to use the python2.7 version of anaconda, but are there any other known
difficulties?

Best,
Kevin




--
View this message in context: http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921p4031453.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

kmader
This post has NOT been accepted by the mailing list yet.
In reply to this post by Steve Pieper-2

Steve Pieper-2 wrote
>> Another option is to build slicer against your locally installed python
>> by pointing cmake to the python install.  This should be doable but is not
>> something we've really explored and documented.
>>
>> -Steve
Has anyone tried this for Anaconda? I would like to have 3d slicer as a package in an existing python environment so that I could simply call functionality from 3D slicer within a web-based python tool. Clearly I will have to use the python2.7 version of anaconda, but are there any other known difficulties?

Best,
Kevin
Reply | Threaded
Open this post in threaded view
|

Re: Using the python installed in system for Slicer

Steve Pieper-2
In reply to this post by kmader
Hi Kevin -

It's a good idea and we've looked at it a few times [1] but it's proven remarkably tricky to get all the parts to work well together in general (slicer builds a different vtk than anaconda, and there are other packages that clash a bit).  Building an installable binary also hasn't been sorted out.  If you only want to support a single target platform and you can build a custom installation from source on that platform it should be doable.

HTH,
Steve

[1] https://www.slicer.org/wiki/Documentation/Labs/SlicerCondaIntegration

On Tue, Dec 20, 2016 at 6:20 AM, kmader <[hidden email]> wrote:


Steve Pieper-2 wrote
>>> Another option is to build slicer against your locally installed python
>>> by pointing cmake to the python install.  This should be doable but is
>>> not
>>> something we've really explored and documented.
>>>
>>> -Steve

Has anyone tried this for Anaconda? I would like to have 3d slicer as a
package in an existing python environment so that I could simply call
functionality from 3D slicer within a web-based python tool. Clearly I will
have to use the python2.7 version of anaconda, but are there any other known
difficulties?

Best,
Kevin




--
View this message in context: http://slicer-users.65878.n3.nabble.com/Using-the-python-installed-in-system-for-Slicer-tp4027921p4031453.html
Sent from the slicer-users mailing list archive at Nabble.com.
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ