Unable to install Python cloudstorage module - google-cloud-storage

I'm using Ubuntu 17.04 on Dell Laptop.
I'm trying to install the cloudstorage module.
When installing the module with Python2 using sudo, it works, however on importing it fails:
python storage2.py
Traceback (most recent call last):
File "storage2.py", line 6, in
import cloudstorage as gcs
File "/home/maxim/.local/lib/python2.7/site-packages/cloudstorage/init.py", line 56
def get_driver(driver: DriverName) -> Drivers:
Also, when I try installing this module with Python3 it fails:
https://apaste.info/QKYD
Why the import fails and how to fix it?
How to install this module in Python3?

Related

bcc: ImportError cannot import name BPF

I am getting the following error when trying run the example hello_world.py.
Traceback (most recent call last):
File "/usr/share/bcc/examples/hello_world.py", line 9, in <module>
from bcc import BPF
ImportError: cannot import name BPF
I installed bcc from source (link).
I also installed both the python bcc bindings packages, python-bcc and python3-bcc but no luck.
I am running Ubuntu 18.04 and kernel version 4.15.0-117-generic.
What am I missing here?
In ubuntu 20.04, I execute the following command to fix it.
sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
I got the issue. I was using the pyenv to manage my python versions, so the python was looking files in the wrong locations.
$ python -c 'import site; print(site.getsitepackages())'
['/home/sagar/.pyenv/versions/3.6.6/lib/python3.6/site-packages']
I tried with a python3 command, which was not installed by pyenv and I don't get the above error.

PyAudio import error : ImportError: DLL load failed: The specified module could not be found

I encountered an import problem by PyAudio.
I have a winodws 10, 64 bit, and use Anaconda and Spyder IDE with python 3.7.
I installed PyAudio in Ananconda, ran as administrator, with these commands :
cd
conda install -c conda-forge PyAudio
The installation ran without any problems.
I then restarted both Anaconda and SPYDER. PyAudio now shows up in Anaconda's list of installed packages.
When I try to import Pyaudio in Spyder (IPython console), I encounter this error message :
[1]: import pyaudio
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "", line 1, in
import pyaudio
File "C:\ProgramData\Anaconda3\lib\site-packages\pyaudio.py", line 116, in
import _portaudio as pa
ImportError: DLL load failed: The specified module could not be found.
I tried to fix it by answers to similar ImportError message issued, while other users tried to import other packages like SKlearn ... , but with no success.
Your problem (and mine) are the same. The issue is, unfortunately, the version of python you're running (in tandem with your OS).
Check out this link:
https://people.csail.mit.edu/hubert/pyaudio/#:~:text=Note%3A%20As%20of%20this%20update,4.
Under the INSTALLATION section in the link for WINDOWS, PyAudio's latest version (0.2.11) is compatible with Python versions: 2.7, 3.4, 3.5, 3.6.
My current python is 3.8.5, so you (and I) could never use PyAudio unless they added compatibilities or we revert to an above python version.
I tried to install portaudio using
conda install portaudio
but it seems like it didn't work as it should be. However,
conda install -c anaconda portaudio
solved the problem.
see the official anaconda page

How can I import libraries in PythonAnywhere and use them in a Python notebook?

I'm both updating and installing packages/libaries, but are only able to use them through the Python3.6 console.
10:40 ~ $ pip3.6 install -U --user scikit-learn
Requirement already up-to-date: scikit-learn in ./.local/lib/python3.6/site-packages
Requirement already up-to-date: numpy>=1.11.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: joblib>=0.11 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: scipy>=0.17.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
When using pip install it fails with :
10:40 ~ $ pip install -U --user scikit-learn
Collecting scikit-learn
Using cached https://files.pythonhosted.org/packages/18/28/5a48b00599b476875415b97bdfdb3849bafb31183c1d785501dbc8a77aa2/scikit-learn-0.22.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-JYw8w1/scikit-learn/setup.py", line 47, in <module>
import sklearn
File "sklearn/__init__.py", line 81, in <module>
from . import __check_build # noqa: F401
File "sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named _check_build
___________________________________________________________________________
Contents of sklearn/__check_build:
__init__.py _check_build.pyx __init__.pyc
setup.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
It appears that you are importing a local scikit-learn source tree. For
this, you need to have an inplace install. Maybe you are in the source
directory and you need to try from another location.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JYw8w1/scikit-learn/
If you've installed a package using pip3.6, make sure that your kernel version for your notebook is 3.6 -- if it's (say) 3.7, then it won't work, because each version of Python has its own separate set of installed modules.
I imported the notebook, and forgot to change Kernel Python3.6. It was still on Python3. Changed notebook to 3.6, and the it used the updated libary's-
When you run pip on PythonAnywhere, outside virtual environment, it installs packages for python2. The latest version of scikit-learn to work with python2 is 0.20.4. So, install it with pip install scikit-learn==0.20.4
You tried to install 0.22.1 with python2.

installing python package in sagemaker sparkmagic pyspark notebook

I want to install new libraries in a running kernel (not bootstrapping). I'm able to create a sagemaker notebook, which is connected to a EMR cluster, but installing package is a headache.
Unable to install packages on notebook. I've tried several methods like installing packages via terminal in jupyterLab.
$ conda install numba
The installation seems to be working fine on conda_pytorch_p36 notebook, but the packages are not installed on SparkMagic (pyspark) notebook.
Error code:
An error was encountered:
No module named numba
Traceback (most recent call last):
ImportError: No module named numba
The jupyter magic command also doesn't work only in pyspark notebook
!pip install keras
Error:
An error was encountered:
invalid syntax (<stdin>, line 1)
File "<stdin>", line 1
!pip install keras
^
SyntaxError: invalid syntax
Based on answer in a github post, neither did this work
from subprocess import call
call("pip install dm-sonnet".split(" "))
when you are running $ conda install numba via the terminal in JupyterLab,
it's actually succeeding the installation on your local environment. The thing is, when you are using Sparkmagic as your kernal, the code in the cells are always running on the spark cluster, not on the local notebook environment. To run the content of a cell locally you should write %%local in the beginning of the cell. After that everything in that cell will run locally and the installed module will be available.
Otherwise you should install the module on the remote spark cluster.
Read more here:
https://github.com/jupyter-incubator/sparkmagic/blob/master/examples/Pyspark%20Kernel.ipynb

PythonAnywhere – How do I use the modules I install?

I'm confused by how I'm supposed to install/use new modules in PythonAnywhere.
For instance, I installed the module ephem in Bash console with
pip3.6 install --user ephem
Everything went alright. If I run the above command again it says;
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: ephem in ./.local/lib/python3.6/site-packages (3.7.7.0)
However, when I try to use it in my script I get:
Traceback (most recent call last): File "/home/krollibrius/montaulieu.py", line 7, in <module> import ephem ModuleNotFoundError: No module named 'ephem'
Can someone help?
Perhaps you used the wrong python version, try adding
import sys
print(sys.version)
to your script. I find that most of the time I install packages to the wrong version.
Another solution could be to use the command pythonwithversionnumber -m pip install --user ephem. Replace pythonwithversionnumber with the command you used to run your script