How to properly install MEEP in Google Colab? - python

In the past I have installed the pymeep package in Google Colab with the following cell:
!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 ./anaconda
import os
os.environ['PATH'] += ":/content/anaconda/bin"
!conda create -n mp -c conda-forge pymeep
import sys
sys.path.append('/content/anaconda/envs/mp/lib/python3.7/site-packages/')
Which is an exact copy from this website: https://rf5.github.io/2019/12/22/meep-intro.html
Sometimes the code I wrote doesn't work. It executes without errors, but when I try to execute import meep as mp. I get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-f30f3b609667> in <module>()
----> 1 import meep
ModuleNotFoundError: No module named 'meep'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Is there a better way of installing meep or rather pymeep in Google Colab?

Replace 3.7 with 3.8 as the latest python version installed using conda is 3.8
sys.path.append('/content/anaconda/envs/mp/lib/python3.8/site-packages/')
Example

Related

error then import pytorch-lightning, azure notebook

i am use microsoft azure (for students) ML servise. Then i work with notebook i can not import pytorch-lightning libary.
!pip install pytorch-lightning==0.9.0
import pytorch_lightning as pl
Here i have error:
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <module>
----> 2 import pytorch_lightning as pl
ModuleNotFoundError: No module named 'pytorch_lightning'
This is unbearably weird. someone faced such a problem?
This is rather strange but could be related to that your installation is in another location, so let's:
try where is PL installed with find -name "lightning"
also, check what is the loaded package locations python -c "import sys; print(sys.path)"
I guess that the problem will be in What's the difference between dist-packages and site-packages?
I resolved this problem by installing PyTorch-lightning in the kernel instead of the machine. It all boils down to installing with %conda magic instead of !conda magic (or same thing for %pip magic instead of !pip magic).

Unable to import 'pandas_profiling' module

I have installed 'pandas_profiling' through conda install -c conda-forge pandas-profiling in the base environment. I could see through the conda list that pandas_profiling has been installed correctly (snapshot attached),
When I try to import pandas_profiling I receive ModuleNotFoundError
import pandas_profiling
Traceback (most recent call last):
File "<ipython-input-4-60d2bac64bfc>", line 1, in <module>
import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'
Update: output of import sys; print(sys.path); print(sys.prefix)
['/home/user1/miniconda3/lib/python38.zip', '/home/user1/miniconda3/lib/python3.8', '/home/user1/miniconda3/lib/python3.8/lib-dynload', '', '/home/user1/miniconda3/lib/python3.8/site-packages', '/home/user1/miniconda3/lib/python3.8/site-packages/IPython/extensions', '/home/user1/.ipython']
/home/user1/miniconda3
This is a frequent issue, check out this entry in the FAQ.
Occasionally you will encounter this error if you import a package from the current notebook. It is important to ensure that the pip version is associated with the current Python kernel. That way, the installed packages can be used in the current notebook.
As detailed here, the shell environment and the Python executable are disconnected.
This should work for you
import sys
!{sys.executable} -m pip install pandas-profiling

Module not found, ffmpeg not found

I have being trying to use the ffmpeg module on anaconda for my recent project.
I am unable to import the package for some reason. I have added/installed ffmpeg to my path environment.
I have tried installing the ffmpeg to the anaconda working file, still it shows
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import ffmpeg
ModuleNotFoundError: No module named 'ffmpeg'
How do i proceed with this,
Can you create a new environment and install ffmeg?
conda create -n my_new_environment -c conda-forge ffmpeg

Pytorch is installed but is not working on ubuntu 18.04

I am trying to install Pytorch via pip on ubuntu 18.04.I have python 3.6 and my laptop is HP-Pavilion notebook 15
The installation seems to be right because i get the message:
Installing collected packages: torch, torchvision Successfully
installed torch-1.3.1+cpu torchvision-0.4.2+cpu
i run the verification code and it is ok
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
However, when i close the terminal or reboot and try to run he same code i get the error:
Traceback (most recent call last):
File "torch.py", line 2, in
import torch
AttributeError: module 'torch' has no attribute 'rand'
How are you executing the python script? Which python are you using? Maybe you installed the package in a different python version?
Try to set alias to the python you want to use:
alias python=/usr/local/bin/python3.6
Then pip install the package with that python alias you will always be using.
python pip install <package name>
Python now will install the package in the python files with the alias python - heading to files: /usr/local/bin/python3.6
Let me know if the error still occurs!
Install pytorch using pip through the below command:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
for any reference go through the official website of pytorch.
Change your file .py to another name, you named torch.py when you import torch it will call ur torch.py

gremlin module not found

I followed the instructions at:
http://joern.readthedocs.io/en/latest/installation.html
to install joern, and then the following to test Joern:
http://joern.readthedocs.io/en/latest/access.html
And got this error (using ipython):
import joern.all
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-903145a12480> in <module>()
----> 1 import joern.all
/home/xxxx/Downloads/python-joern-0.3.1/joern/all.py in <module>()
1 from py2neo import Graph
----> 2 from py2neo.ext.gremlin import Gremlin
3 import os
4
5 DEFAULT_GRAPHDB_URL = "http://localhost:7474/db/data/"
ImportError: No module named gremlin
Can someone teach me how to install "Gremlin"?
I did the following and it is still not working:
## wget -O neo4j-gremlin.zip http://mlsec.org/joern/lib/neo4j-gremlin-plugin-2.1-SNAPSHOT-server-plugin.zip
sudo mkdir -p /usr/share/neo4j/plugins/gremlin-plugin
sudo unzip neo4j-gremlin.zip -d /usr/share/neo4j/plugins/gremlin-plugin
and the "0.1.tar.gz" have installed the py2neo-gremlin-0.1 as well.
And "pip install Gremlin" does not worked too.
Now I have run out of idea.
You most likely have a version of py2neo installed that is incompatible with Joern. If you used pip to install py2neo, you will get v3.x but Joern appears to only support v2.0 at the moment. Run the following command to confirm:
python -c "import py2neo; print py2neo.__version__"
If the above does not print 2.0, remove py2neo by running pip uninstall py2neo and then install v2.0 specifically by running pip install py2neo==2.0. Then re-test by running python -c "from py2neo.ext.gremlin import Gremlin" - it should complete without errors.

Categories