How to Import Python Modules into Spyder

12,029 views
Skip to first unread message

Chrise123

unread,
Jun 14, 2015, 5:43:59 AM6/14/15
to spyd...@googlegroups.com
Hi,

Spyder is a great IDE; it works straight away after installation and is intuitive to use. It is an excellent product and a credit to the developers.!

My problem is that I would like to use other Python modules within Spyder, e.g., Metis. I have reviewed the posts that discuss this issue and have tried to follow the advice, but with no success. All the advice assumes a level of knowledge about unix installations (and wrappers) that exceeds my ability to interpret that advice.

I think it would be really useful if there was some way to utilise the vast range of Python modules from with Spyder; perhaps with an installer like pip. Am I being naive in thinking that this might be possible?

In the meantime can someone tell me how to import modules such as Metis or PyMetis into Spyder in a way that does not assume a great deal of unix expertise?


Adrian Klaver

unread,
Jun 14, 2015, 9:36:59 AM6/14/15
to spyd...@googlegroups.com
On 06/14/2015 02:43 AM, Chrise123 wrote:
> Hi,
>
> Spyder is a great IDE; it works straight away after installation and is
> intuitive to use. It is an excellent product and a credit to the
> developers.!
>
> My problem is that I would like to use other Python modules within
> Spyder, e.g., Metis. I have reviewed the posts that discuss this issue
> and have tried to follow the advice, but with no success. All the advice
> assumes a level of knowledge about unix installations (and wrappers)
> that exceeds my ability to interpret that advice.
>
> I think it would be really useful if there was some way to utilise the
> vast range of Python modules from with Spyder; perhaps with an installer
> like pip. Am I being naive in thinking that this might be possible?

Just import them in your code or the console. The modules do not live in
Spyder, just where ever you normally install them.

>
> In the meantime can someone tell me how to import modules such as Metis
> or PyMetis into Spyder in a way that does not assume a great deal of
> unix expertise?
>
>
> --



--
Adrian Klaver
adrian...@aklaver.com

Chris Edwards

unread,
Jun 14, 2015, 8:40:49 PM6/14/15
to spyd...@googlegroups.com
OK and thanks.

I installed networkx and can now import it in Spyder.

Next I go to https://metis.readthedocs.org/en/latest/ and try to install metis (as su) using pip.

I get the following result

cbhe:pip install metis
Collecting metis
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90:
InsecurePlatformWarning: A true SSLContext object is not available.
This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Could not find a version that satisfies the requirement metis (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external metis to allow).
No matching distribution found for metis

So now I am back in the murky depths of a unix-python-module interaction.

Any suggestions as to how to get out of this quicksand?
> --
> You received this message because you are subscribed to a topic in the Google Groups "spyder" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/spyderlib/OVxEjMp_TB8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to spyderlib+...@googlegroups.com.
> To post to this group, send email to spyd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/spyderlib.
> For more options, visit https://groups.google.com/d/optout.

Adrian Klaver

unread,
Jun 14, 2015, 9:27:33 PM6/14/15
to spyd...@googlegroups.com
On 06/14/2015 05:40 PM, Chris Edwards wrote:
> OK and thanks.
>
> I installed networkx and can now import it in Spyder.
>
> Next I go to https://metis.readthedocs.org/en/latest/ and try to install metis (as su) using pip.
>
> I get the following result
>
> cbhe:pip install metis
> Collecting metis
> /Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90:
> InsecurePlatformWarning: A true SSLContext object is not available.
> This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
> For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

Follow the above link for more information.

> InsecurePlatformWarning
> Could not find a version that satisfies the requirement metis (from versions: )
> Some externally hosted files were ignored as access to them may be unreliable (use --allow-external metis to allow).
> No matching distribution found for metis

Try:

pip install metis --pre

See answer in SO here:

http://stackoverflow.com/questions/18230956/could-not-find-a-version-that-satisfies-the-requirement-pytz
--
Adrian Klaver
adrian...@aklaver.com

Chris Edwards

unread,
Jun 16, 2015, 9:22:43 PM6/16/15
to spyd...@googlegroups.com
As suggested I went to the link https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning, and followed the instructions as far as I could with the following result

cbhe:python
Python 2.7.9rc1 (v2.7.9rc1:40eada278702, Nov 25 2014, 17:25:50) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ^D
cbhe:pip install certifi
Requirement already satisfied (use --upgrade to upgrade): certifi in /Library/Python/2.7/site-packages
cbhe:

I think that tells me that certificates are installed correctly but I might be misunderstanding this. As suggested I then tried pip install metis --pre and got the following

cbhe:pip install metis --pre
Collecting metis
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Could not find a version that satisfies the requirement metis (from versions: )
  Some externally hosted files were ignored as access to them may be unreliable (use --allow-external metis to allow).
No matching distribution found for metis
cbhe:

Further instructions about updating and using certificates are beyond my ability to follow. So I am still in the unix-python-module swamp and yearning for a simple life where I can use Spyder for actually doing something.

Any suggestions as to where to go from here?

Adrian Klaver

unread,
Jun 16, 2015, 9:59:02 PM6/16/15
to spyd...@googlegroups.com
On 06/16/2015 06:22 PM, Chris Edwards wrote:
> As suggested I went to the link
> https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning,
> and followed the instructions as far as I could with the following result
>
> /cbhe:python/
> /Python 2.7.9rc1 (v2.7.9rc1:40eada278702, Nov 25 2014, 17:25:50) /
> /[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin/
> /Type "help", "copyright", "credits" or "license" for more information./
> />>> import ssl/
> />>> ^D/
> /cbhe:pip install certifi/
> /Requirement already satisfied (use --upgrade to upgrade): certifi in
> /Library/Python/2.7/site-packages/
> /cbhe:/

So did you do as the above suggested?:

pip install --upgrade certifi

>
> I think that tells me that certificates are installed correctly but I
> might be misunderstanding this. As suggested I then tried /pip install
> metis --pre/ and got the following

>
> /cbhe:pip install metis --pre/
> /Collecting metis/
> //Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90:
> InsecurePlatformWarning: A true SSLContext object is not available. This
> prevents urllib3 from configuring SSL appropriately and may cause
> certain SSL connections to fail. For more information, see
> https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning./
> / InsecurePlatformWarning/
> / Could not find a version that satisfies the requirement metis (from
> versions: )/
> / Some externally hosted files were ignored as access to them may be
> unreliable (use --allow-external metis to allow)./
> /No matching distribution found for metis/
> /cbhe:/


Again did you do as suggested?:


pip install --allow-external metis --pre


FYI, error messages/tracebacks are just not there to take space, they
have important information.

>
> Further instructions about updating and using certificates are beyond my
> ability to follow. So I am still in the unix-python-module swamp and
> yearning for a simple life where I can use Spyder for actually doing
> something.

This has nothing to with either Spyder or Unix. You would see the same
issues on Windows.

What it is related to is that Metis is alpha software. If you want to
live on the bleeding edge, then you better expect some blood to be spilled.

>
> Any suggestions as to where to go from here?
>
>> On 15 Jun 2015, at 11:27 am, Adrian Klaver <adrian...@aklaver.com
> You received this message because you are subscribed to the Google
> Groups "spyder" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to spyderlib+...@googlegroups.com
> <mailto:spyderlib+...@googlegroups.com>.
> To post to this group, send email to spyd...@googlegroups.com
> <mailto:spyd...@googlegroups.com>.

Chris Edwards

unread,
Jun 17, 2015, 12:01:56 AM6/17/15
to spyd...@googlegroups.com
OK I did as suggested with the following results

cbhe:pip install --upgrade certifi
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Requirement already up-to-date: certifi in /Library/Python/2.7/site-packages
cbhe:pip install --allow-external metis --pre
You must give at least one requirement to install (see "pip help install")
cbhe:

I went to pip help install and tried several install requirements but none of them worked for me.

I had not realised that metis was ‘alpha software’ when I visited https://metis.readthedocs.org/en/latest/#. I understood it to be available and the example code looked just what I was looking for.

Are you able to execute that example as below? If so perhaps it might help to isolate my problem.

>>> import networkx as nx
>>> import metis
>>> G = metis.example_networkx()
>>> (edgecuts, parts) = metis.part_graph(G, 3)
>>> colors = ['red','blue','green']
>>> for i, p in enumerate(parts):
...     G.node[i]['color'] = colors[p]
...
>>> nx.write_dot(G, 'example.dot') # Requires pydot or pygraphviz

Adrian Klaver

unread,
Jun 17, 2015, 9:28:22 AM6/17/15
to spyd...@googlegroups.com
On 06/16/2015 09:01 PM, Chris Edwards wrote:
> OK I did as suggested with the following results
>
> /cbhe:pip install --upgrade certifi/
> //Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90:
> InsecurePlatformWarning: A true SSLContext object is not available. This
> prevents urllib3 from configuring SSL appropriately and may cause
> certain SSL connections to fail. For more information, see
> https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning./
> / InsecurePlatformWarning/
> /Requirement already up-to-date: certifi in
> /Library/Python/2.7/site-packages/
> /cbhe:pip install --allow-external metis --pre/
> /You must give at least one requirement to install (see "pip help install")/
> /cbhe:/
> /
> /
> I went to /pip help install/ and tried several install requirements but
> none of them worked for me.
>
> I had not realised that metis was ‘alpha software’ when I visited
> https://metis.readthedocs.org/en/latest/#. I understood it to be
> available and the example code looked just what I was looking for.

Well the below in the documentation is wrong :
"
It’s on PyPI, so installation should be as easy as:

pip install metis
-or-
easy_install metis
"

There is no actual file on PyPi. To get it to install, I went to(from
the Download URL on the PyPi page) to here:

https://bitbucket.org/kw/metis-python/downloads

and downloaded the repo, unzipped it and then ran:

python setup.py install

If it where me I would go here:

https://bitbucket.org/kw/metis-python

and file a bug report

FYI the last commit to the code was 2013-10-10. so I would not hold out
great hopes.

>
> Are you able to execute that example as below? If so perhaps it
> might help to isolate my problem.

No, because I do not have Metis or Networkx installed.
>
>>>>import networkx as nx
>>>>import metis
>>>>G = metis.example_networkx()
>>>>(edgecuts, parts) = metis.part_graph(G, 3)
>>>>colors = ['red','blue','green']
>>>>for i, p in enumerate(parts):
> ... G.node[i]['color'] = colors[p]
> ...
>>>>nx.write_dot(G, 'example.dot') # Requires pydot or pygraphviz
>
>
>



--
Adrian Klaver
adrian...@aklaver.com

Chrise123

unread,
Jun 21, 2015, 7:25:24 AM6/21/15
to spyd...@googlegroups.com
Thanks for the information.
It looks like I have been chasing a mirage and have wasted great deal of time. This is very frustrating because Metis and PyMetis appear to be what I need.
I went to https://bitbucket.org/kw/metis-python and tried to file a bug report but I am not sure that I succeeded. The website is not exactly set up for end users of the products. 
Can you suggest where I might go (as a user) to find help in getting this software installed and running in Spyder?

Adrian Klaver

unread,
Jun 21, 2015, 9:21:28 AM6/21/15
to spyd...@googlegroups.com
On 06/21/2015 04:25 AM, Chrise123 wrote:
> Thanks for the information.
> It looks like I have been chasing a mirage and have wasted great deal of
> time. This is very frustrating because Metis and PyMetis appear to be
> what I need.
> I went to https://bitbucket.org/kw/metis-python
> <https://www.google.com/url?q=https%3A%2F%2Fbitbucket.org%2Fkw%2Fmetis-python&sa=D&sntz=1&usg=AFQjCNHFUt0C8t3-4u2PAKFn-T9qhJLEoQ> and
> tried to file a bug report but I am not sure that I succeeded. The
> website is not exactly set up for end users of the products.
> Can you suggest where I might go (as a user) to find help in getting
> this software installed and running in Spyder?

First you will not be installing it in Spyder, you will be installing it
on your system where any Python program can reach it.

Second I gave you the instructions for how to install it below.
> <https://metis.readthedocs.org/en/latest/#>. I understood it to be
> adrian...@aklaver.com <javascript:>

David Verelst

unread,
Jun 21, 2015, 11:43:34 AM6/21/15
to spyder
Hi,

How to install additional Python modules depends strongly on which platform you are and whether you are using your systems Python install, a virtual environment or a standalone Python distribution (such as Anaconda, Canopy, WinPython, PythonXY, or others). Based on some of your replies I can see that you are running Python on a Mac with OSX. I am not a Mac user, so I can only help you by pointing to some general resources that might help you.

Have you installed Spyder via anaconda or the dmg installer? (see also the spyder installation docs here)?
I would suggest to try out Anaconda. Anaconda installs as a standalone python distribution (that includes Spyder) and has a package manager called conda (which is a pip alternative). The anaconda package repository is called binstar, and contains pymetis. The nice thing about anaconda package is that they come in a compiled form which makes it much easier to install (at least if a binary package for you system is available). Have you tried installing Anaconda, and does it work installing PyMetis in there? But please make sure to read quick start guide and the online documentation as indicated on the Anaconda web page.

As mentioned by Adrian, notice that METIS for Python (https://bitbucket.org/kw/metis-python) is not being maintained any more (last commit in September 2013). Do not confuse this package with PyMetis, which stills seems to be maintained, and I would recommend using PyMetis over Python for METIS (disclaimer: I am guessing as I have tested nor compared any).

You indicate that PyMetis and Spyder are products. Depending on your definition of products, I would argue they are not. Spyder for example is run by people who love coding and it is maintained by people who do it out of passion. There is absolutely no money involved. You are asking for simple and straightforward advice (that does not require a great deal of UNIX experience). As volunteers we can only do our best, but we are not paid support workers, and as such we can only spent limited resources with helping to solve your specific problem. If you are used to an environment like MATLAB (for which you might have paid a lot of money), you will find that installing 3th party modules (such as METIS) can be more challenging in some cases with Python.

If you want to interact with the METIS/PyMetis developers you will have to learn to how to use the issue trackers of Github and Bitbucket. That is where users and developers can interact with each other (besides a mailing list such as this one). You will see it is not that difficult, and once you understand you'll see why all open source developers and users are using these tools: they are extremely helpful in managing problems, bugs and issues of software that is developed and used by people all over the world and that in most cases haven't even met each other.

As a final note: I have the impression that the main problem here is that you do not know how to install modules in Python in general. Have you considered asking someone to explain you the basics in person?

Best regards,
David


To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.

David Verelst

unread,
Jun 21, 2015, 12:29:00 PM6/21/15
to spyder
Correction: I've just had a quick look at how to install pymetis with anaconda, and it might be slightly more complicated then doing "conda install pymetis"... I don't know what the quickest and easiest way is to install pymetis on a Mac. But Google is your friend (install pymetis osx):
https://github.com/echu/dist_ecos
I have no idea if it will work, but at least it contains some instructions that may (or may not) help you.

David
Reply all
Reply to author
Forward
0 new messages