When I run:
from google.colab import auth
I get this error:
ModuleNotFoundError: No module named 'google.colab'
This module is required for accessing files on Google drive from python. How can I resolve this error?
You can simply download google-colab and use it in local.
pip install google-colab
If you want to run google-colab from your local machine and you want to install if via conda, just type the following:
conda install -c conda-forge google-colab
For reference: https://anaconda.org/conda-forge/google-colab
AFAIK, you can execute the module 'google.colab' from within the notebook environment of colab.research.google.com (it is not a publicly available package)
OFF-TOPIC:
Looking at the tag conda in your question. I assume that you are running the code from your local machine. Please make use of PyDrive to read from google drive on your local machine.
References:
Google Colaboratory FAQ
PyDrive
11
You can use !setup.py install to do that.
Colab is just like a Jupyter notebook. Therefore, we can use the ! operator here to install any package in Colab. What ! actually does is, it tells the notebook cell that this line is not a Python code, its a command line script. So, to run any command line script in Colab, just add a ! preceding the line.
For example: !pip install tensorflow. This will treat that line (here pip install tensorflow) as a command prompt line and not some Python code. However, if you do this without adding the ! preceding the line, it'll throw up an error saying "invalid syntax".
But keep in mind that you'll have to upload the setup.py file to your drive before doing this (preferably into the same folder where your notebook is).
Hope this answers your question
Related
I usually use SCIP (call PyScipOpt) with Jupyter Notebook (installed via Anaconda) on my Mac, and when I write "from pyscipopt import Model" there is no error (when running it on my machine) but for the large-scale problems I decided to import my notebook to Google Colab and run the code there. Cannot get rid of the error: "no module named pyscipopt".
I tried "!pip install pyscipopt" directly in google colab, and "!apt install pyscipopt". While executing "!pip install pyscipopt", I got another error: "failed building wheel for pyscipopt". When I googled it, I found that the SCIP should be installed prior etc. but I said everything is working fine on Jupyter Notebook directly on my Mac which means SCIP is installed and lib and include subpackages are there (I checked). I also tried "export SCIPOPTDIR=" and "!export SCIPOPTDIR=". Nothing works.
Any advise would be much appreciated.
Thanks!
Lidiia
From pip or PyPI you cannot install SCIP but only PySCIPOpt. You need to use the conda package that includes SCIP to use PySCIPOpt in a hosted Google Colab notebook.
First, you need to install conda itself:
!pip install -q condacolab
import condacolab
condacolab.install()
Then, you can install PySCIPOpt:
!conda install pyscipopt
Finally, you can import PySCIPOpt as usual:
from pyscipopt import Model
m = Model()
m.redirectOutput()
m.printVersion()
TL;DR How do I install AWS X-Ray sdk, because the pip install doesn't seem to get the full package
Hello Folks,
I'm working on trying out AWS X-Ray for my Python lambda. I know the library is large, but I wanted to get a POC before putting it into a layer. The issue is that when I install it, it doesn't seem to get installed.
When I run pip install -r requirements.txt I see that it installs two packages, aws_xray_sdk and aws_xray_sdk-2.9.0.dist-info. When I look into these packages I see that they are 740 kilobytes altogether (makes me think this is a stub of some sort)
When I upload my lambda and test it, I get the following error even though the directories are in my venv:
[ERROR] Runtime.ImportModuleError: Unable to import module 'users/main': No module named 'aws_xray_sdk' Traceback (most recent call last):
Any help is greatly appreciated.
To install the X-Ray SDK for Python, you simply do pip install aws-xray-sdk and that should work. This is explained in the documentation.
If this is not working, there is something else that's wrong with your setup.
The issue was that I was not putting my dependencies in the root of my .zip file as the docs clearly show ='(
4. Create a deployment package with the installed libraries at the root.
When I install OpenCV, I get an error as shown below. What should I do?
ImportError: DLL load failed: The specified module could not be found.
Installing OpenCV
To install a package in Jupyter Notebook, you can use the magic %pip command.
%pip install opencv-python
If the above command doesn't work on IPython < 7.3, you can try this command instead.
!pip install --user opencv-python
Demonstration
Let's see it in action. First, you insert a new cell, type in either of the two commands above, and then execute the cell using the Ctrl + Enter shortcut.
You should now be able to import and use OpenCV without any errors.
This is usually a dependency issue. Just .pyd is not enough (all .DLLs are required).
On Windows add entries to .dll into PATH environment variable (not enough for Python 3.8 with updated security policies)
I want to run a docker image in azure as a container. In visual studio Code everything works fine. But azure has problems with "from azure.servicebus import QueueClient" I get the errormessage:
"File "./main.py", line 11, in
from azure.servicebus import QueueClient, Message
ModuleNotFoundError: No module named 'azure' "
I want to unstall the package azure-servicebus
How can I do that?
azure-servicebus package can be installed in the docker image using
pip install azure-servicebus
More information about package can be found at https://pypi.org/project/azure-servicebus/
However how to install it via Dockerfile it will depends on how are you installing other dependent packages (maybe via requirements.txt file or directly installing via pip or using other packager like conda etc). If you are able to post sample Dockerfile, we could suggest changes in the file which could work immediately.
I am a making a very simple API call to the Google Vision API, but all the time it's giving me error that 'google.oauth2' module not found. I've pip installed all the dependcies. To check this, I've imported google.oauth2 module in command line Python and It's working there. Please help me with this.
There are multiple reasons for this:
Check whether you have installed dependencies in only one place or multiple places. Try to install it only in the source library folder.
If above doesn't solve uninstall all Google packages from your local machine, delete the lib folder in your app folder, create it again and then execute:
pip install -t lib google-auth google-auth-httplib2 google-api-python-client --upgrade
Hope this should solve your problem!!