Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Instructions for Google Colab Platform #460

Open
sugatoray opened this issue Aug 9, 2018 · 16 comments
Open

Installation Instructions for Google Colab Platform #460

sugatoray opened this issue Aug 9, 2018 · 16 comments

Comments

@sugatoray
Copy link

sugatoray commented Aug 9, 2018

The google colab platform runs on Ubuntu version: "17.10 (Artful Aardvark)"
I tried installing Meep by using the following command and the installation failed. Please provide a working set of commands or other means to be able to use Meep in Google Colab Platform.

Command used in Colab to install meep:

!apt-get install meep h5utils

Google Colaboratory Platform: https://colab.research.google.com

@ChristopherHogan
Copy link
Contributor

This seems to work:

!wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!bash ./Miniconda3-latest-Linux-x86_64.sh -b -p /usr/local
!conda install -y -c chogan -c conda-forge pymeep

import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')
import meep as mp

@ChristopherHogan
Copy link
Contributor

Did that solve your problem @sugatoray?

@sugatoray
Copy link
Author

sugatoray commented Aug 23, 2018

Hello @ChristopherHogan thank you for replying. I tried your solution and got an error for the following command:

!bash ./Miniconda3-latest-Linux-x86_64.sh -b -p /usr/local

The error was:

ERROR: File or directory already exists: '/usr/local'
If you want to update an existing installation, use the -u option.

I am not very savvy with which options I should use and what the command would look like then. If you could kindly help me out here I will really appreciate that.

@sugatoray
Copy link
Author

Okay, I made some progress but got stuck at another error. I changed the command !bash ./Miniconda3... to the following one and it worked with a warning message:

!bash ./Miniconda3-latest-Linux-x86_64.sh -b -u /usr/local

The warning message was:

WARNING:
    You currently have a PYTHONPATH environment variable set. This may cause
    unexpected behavior when running the Python interpreter in Miniconda3.
    For best results, please verify that your PYTHONPATH only points to
    directories of packages that are compatible with the Python interpreter
    in Miniconda3: /root/miniconda3

When I tried running the following command I got an error:
!conda install -y -c chogan -c conda-forge pymeep
The error was:

/bin/sh: 1: conda: not found

@ChristopherHogan
Copy link
Contributor

I don't know anything about Google Colaboratory but it seems to save the VM state and prevent modifications to PATH. If I !rm -rf /usr/local and run the my instructions again, it works. You must already have stuff installed in /usr/local though. My instructions only work in a fresh state. I'm having difficulty installing miniconda into any other location because of the inability to modify PATH or PYTHONPATH, and the lack of the source command.

@sugatoray
Copy link
Author

Thank you @ChristopherHogan.

@biranchi2018
Copy link

This this for setting the pythonpath,
import os
os.environ['PYTHONPATH'] = "/usr/bin/python3"

@8192A
Copy link

8192A commented Dec 2, 2019

I did !rm '-rf /usr/local' before I run @sugatoray instruction, but I received the following error.
'''
ModuleNotFoundError Traceback (most recent call last)
in ()
7 import sys
8 sys.path.append('/usr/local/lib/python3.6/site-packages/')
----> 9 import meep as mp

ModuleNotFoundError: No module named 'meep'
'''
There's no error during the installation. I wonder if anyone have the same problem and will really appreciate anyone who help me out.

@Alex-l-r
Copy link

I've tried running
!pip install meep

And with that it works importing meep in google colab, but when you call functions like Vector3, Medium, etc. It tells you

AttributeError: module 'meep' has no attribute 'Medium'
Any ideas to overcome this?

Thanks !

@danielwboyce
Copy link

@Alex-l-r The meep package in PyPI (pip) isn't our meep. As far as I know the only available precompiled packages for meep come from conda-forge, so there wouldn't be a meep build in PyPI (or the APT library) at all.

@Alex-l-r
Copy link

@danielwboyce then i don't know what I have installed there lol. Thanks for the answer !

Then i'm back the point of @8192A of using the commands given up there but unable to import meep

@pierreluc-plt
Copy link

Hi,
Here is the somewhat strange procedure that I use:

First, run the following lines:
import os os.environ['PYTHONPATH'] = "/usr/bin/python3" !wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local

After, I reset the environment :
image

After that, I run these lines
!conda install gsl=2.2.1 !conda install -y -c chogan -c conda-forge pymeep !apt-get install meep h5utils import sys sys.path.append('/usr/local/lib/python3.6/site-packages/') import meep as mp

I am not sure that all the lines are necessary but it seems to work...

@pierreluc-plt
Copy link

Hi,
Here is the somewhat strange procedure that I use:

First, run the following lines:
import os os.environ['PYTHONPATH'] = "/usr/bin/python3" !wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local

After, I reset the environment :
image

After that, I run these lines
!conda install gsl=2.2.1 !conda install -y -c chogan -c conda-forge pymeep !apt-get install meep h5utils import sys sys.path.append('/usr/local/lib/python3.6/site-packages/') import meep as mp

I am not sure that all the lines are necessary but it seems to work...

This way of installing meep on colab doesn't seem to work anymore with the new release. Using the same steps, i get the following error:

`ImportError Traceback (most recent call last)
in ()
23 import sys
24 sys.path.append('/usr/local/lib/python3.6/site-packages/')
---> 25 import meep as mp

/usr/local/lib/python3.6/site-packages/meep/init.py in ()
6
7 from sys import version_info as _swig_python_version_info
----> 8 from . import _meep
9 del _swig_python_version_info
10

ImportError: libctlgeom.so.6: cannot open shared object file: No such file or directory

---------------------------------------------------------------------------`
Do you have any idea how this problem can be solved? Is anyone using the new version on colab?

Thanks

@Alex-l-r
Copy link

Hi,
Here is the somewhat strange procedure that I use:
First, run the following lines:
import os os.environ['PYTHONPATH'] = "/usr/bin/python3" !wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local
After, I reset the environment 👍
After that, I run these lines
!conda install gsl=2.2.1 !conda install -y -c chogan -c conda-forge pymeep !apt-get install meep h5utils import sys sys.path.append('/usr/local/lib/python3.6/site-packages/') import meep as mp
I am not sure that all the lines are necessary but it seems to work...

This way of installing meep on colab doesn't seem to work anymore with the new release. Using the same steps, i get the following error:

`ImportError Traceback (most recent call last)
in ()
23 import sys
24 sys.path.append('/usr/local/lib/python3.6/site-packages/')
---> 25 import meep as mp

/usr/local/lib/python3.6/site-packages/meep/init.py in ()
6
7 from sys import version_info as _swig_python_version_info
----> 8 from . import _meep
9 del _swig_python_version_info
10

ImportError: libctlgeom.so.6: cannot open shared object file: No such file or directory

---------------------------------------------------------------------------`
Do you have any idea how this problem can be solved? Is anyone using the new version on colab?

Thanks

Hello @pierreluc-plt

currently I've been able to make it work in the actual version of google collab with this:

import sys
# Download miniconda
!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!bash Miniconda3-latest-Linux-x86_64.sh -bfp /usr/local
# Install packages from Anaconda
!conda install -y -c conda-forge --prefix /usr/local pymeep
# Append path to be able to run packages installed with conda
sys.path.append('/usr/local/lib/python3.7/site-packages')

Then you can load meep

import meep as mp
import numpy as np
import matplotlib.pyplot as plt

And the you should be able to run it. It has the drawback of downloading and installing meep everytime you open the notebook, since collab can use Google Drive sure must be a way to have it downloaded there and just "load" those files, but well, it works fine and you are sure you have always the last version of meep.

I hope this helps :)

@pierreluc-plt
Copy link

Hi,
Here is the somewhat strange procedure that I use:
First, run the following lines:
import os os.environ['PYTHONPATH'] = "/usr/bin/python3" !wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh && bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local
After, I reset the environment 👍
After that, I run these lines
!conda install gsl=2.2.1 !conda install -y -c chogan -c conda-forge pymeep !apt-get install meep h5utils import sys sys.path.append('/usr/local/lib/python3.6/site-packages/') import meep as mp
I am not sure that all the lines are necessary but it seems to work...

This way of installing meep on colab doesn't seem to work anymore with the new release. Using the same steps, i get the following error:
ImportError Traceback (most recent call last) in () 23 import sys 24 sys.path.append('/usr/local/lib/python3.6/site-packages/') ---> 25 import meep as mp /usr/local/lib/python3.6/site-packages/meep/**init**.py in () 6 7 from sys import version_info as _swig_python_version_info ----> 8 from . import _meep 9 del _swig_python_version_info 10 ImportError: libctlgeom.so.6: cannot open shared object file: No such file or directory ---------------------------------------------------------------------------
Do you have any idea how this problem can be solved? Is anyone using the new version on colab?
Thanks

Hello @pierreluc-plt

currently I've been able to make it work in the actual version of google collab with this:

import sys
# Download miniconda
!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!bash Miniconda3-latest-Linux-x86_64.sh -bfp /usr/local
# Install packages from Anaconda
!conda install -y -c conda-forge --prefix /usr/local pymeep
# Append path to be able to run packages installed with conda
sys.path.append('/usr/local/lib/python3.7/site-packages')

Then you can load meep

import meep as mp
import numpy as np
import matplotlib.pyplot as plt

And the you should be able to run it. It has the drawback of downloading and installing meep everytime you open the notebook, since collab can use Google Drive sure must be a way to have it downloaded there and just "load" those files, but well, it works fine and you are sure you have always the last version of meep.

I hope this helps :)

It works! Thanks @Alex-l-r !

@CodeIron
Copy link

To install meep in colab I ran the code:-

import sys

Download miniconda

!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!bash Miniconda3-latest-Linux-x86_64.sh -bfp /usr/local

Install packages from Anaconda

!conda install -y -c conda-forge --prefix /usr/local pymeep

Append path to be able to run packages installed with conda

sys.path.append('/content/anaconda/envs/mp/lib/python3.8/site-packages/')

and when I run :-
cell = mp.Vector3(16,8,0)

I get the error:-

AttributeError Traceback (most recent call last)
in ()
----> 1 cell = mp.vector3(16,8,0)

AttributeError: module 'meep' has no attribute 'vector3'

Any help would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants