How to install DBT CLI on GCP? - dbt

I've installed DBT CLI on GCP cloud shell using pip install dbt after that I had added the path to dbt in my .profile file too -
.profile file -
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$HOME/.local/lib/python3.9/site-packages:$PATH"
fi
export $PATH
After the above steps, now when I test the commands like - dbt --version it gives below error -
my_name#cloudshell:~$ dbt --init
Traceback (most recent call last):
File "/home/my_name/.local/bin/dbt", line 5, in <module>
from dbt.main import main
File "/home/my_name/.local/lib/python3.9/site-packages/dbt/main.py", line 11, in <module>
import dbt.version
File "/home/my_name/.local/lib/python3.9/site-packages/dbt/version.py", line 11, in <module>
import dbt.semver
File "/home/my_name/.local/lib/python3.9/site-packages/dbt/semver.py", line 8, in <module>
import dbt.utils
File "/home/my_name/.local/lib/python3.9/site-packages/dbt/utils.py", line 9, in <module>
import jinja2
File "/home/my_name/.local/lib/python3.9/site-packages/jinja2/__init__.py", line 12, in <module>
from .environment import Environment
File "/home/my_name/.local/lib/python3.9/site-packages/jinja2/environment.py", line 25, in <module>
from .defaults import BLOCK_END_STRING
File "/home/my_name/.local/lib/python3.9/site-packages/jinja2/defaults.py", line 3, in <module>
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "/home/my_name/.local/lib/python3.9/site-packages/jinja2/filters.py", line 13, in <module>
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.9/dist-packages/markupsafe/__init__.py)
Where have I failed? Can anyone please correct me?

Try pip install dbt-[adapter] (eg dbt-bigquery) which will install the latest version of dbt, rather than the pre-1.0 version you’re getting now (which has become broken due to an issue with a dependency).

Related

E: Package 'python3-distutils' has no installation candidate

I am currently using the Google core dev board and using Putty to enter the code.
While performing the code, I got the error as below.
Traceback (most recent call last):
File "tools/generate_detections.py", line 7, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
So I typed sudo pip install tensorflow.
but I got another error as below.
Traceback (most recent call last):
File "/home/mendel/.local/bin/pip", line 6, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/configuration.py", line 27, in <module>
from pip._internal.utils.misc import ensure_dir, enum
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/misc.py", line 42, in <module>
from pip._internal.locations import get_major_minor_version, site_packages, user_site
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/locations/__init__.py", line 14, in <module>
from . import _distutils, _sysconfig
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/locations/_distutils.py", line 9, in <module>
from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'
So I typed sudo apt install python3-distutils.
but I got another error as below.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3-distutils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libpython3.7-stdlib
E: Package 'python3-distutils' has no installation candidate
I can no longer find a solution.
Is there anyone who can help me?
sudo apt install python3-distutils
Just install in your Ubuntu terminal after you can install other packages!

Getting Error while running python3 main.py file

I am getting this error,
/tmp/Python-3.7.5$ python3 main.py
Traceback (most recent call last):
File "main.py", line 3, in <module>
import pandas as pd
File "/home/abc/.local/lib/python3.7/site-packages/pandas/__init__.py", line 51, in <module>
from pandas.core.api import (
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/api.py", line 31, in <module>
from pandas.core.groupby import Grouper, NamedAgg
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/groupby/__init__.py", line 1, in <module>
from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/groupby/generic.py", line 65, in <module>
from pandas.core.frame import DataFrame
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 119, in <module>
from pandas.core import algorithms, common as com, generic, nanops, ops
File "/home/abc/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 112, in <module>
from pandas.io.formats import format as fmt
File "/home/abc/.local/lib/python3.7/site-packages/pandas/io/formats/format.py", line 77, in <module>
from pandas.io.common import stringify_path
File "/home/abc/.local/lib/python3.7/site-packages/pandas/io/common.py", line 3, in <module>
import bz2
File "/usr/local/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
what is the solution?
How did you install your Python? If you've manually built it or used the make command, you might be missing the bz2 library headers.
Try the following...
Centos/Fedora/RHEL:
sudo yum install bzip2-devel
Debian and Ubuntu:
sudo apt-get install libbz2-dev
You'll then either need to rebuild your Python installation or to copy the header in your Python folder, with:
sudo cp /usr/lib/python3.7/lib-dynload/_bz2.cpython-38-x86_64-linux-gnu.so /usr/local/lib/python3.7/

after installing odoo12 community I am getting Import error

After installing Odoo 12 Community in Ubuntu 16.04 from https://www.odoo.yenthevg.com/installing-odoo-12-enterprise-ubuntu/
I am getting following error:
Traceback (most recent call last):
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo-bin", line 5, in <module>
import odoo
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/__init__.py", line 89, in <module>
from . import modules
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/modules/__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/modules/graph.py", line 10, in <module>
import odoo.tools as tools
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/tools/__init__.py", line 8, in <module>
from .config import config
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/tools/config.py", line 18, in <module>
from passlib.context import CryptContext
File "/usr/local/lib/python3.5/dist-packages/passlib/context.py", line 20, in <module>
from passlib.registry import get_crypt_handler, _validate_handler_name
File "/usr/local/lib/python3.5/dist-packages/passlib/registry.py", line 11, in <module>
from passlib.utils import is_crypt_handler
File "/usr/local/lib/python3.5/dist-packages/passlib/utils/__init__.py", line 32, in <module>
from passlib.utils.compat import add_doc, b, bytes, join_bytes, join_byte_values, \
ImportError: cannot import name 'b'
I already have Odoo 12 Enterprise version, but after installing Odoo 12 Community, getting same error in Odoo 12 Enterprise.
Please try this.
sudo pip3 install passlib==1.6.5
sudo -H pip3 install --upgrade pip
sudo -H pip3 install pipenv

ImportError: liblapack.so.3gf: cannot open shared object file: No such file or directory

I have both python 2.7.16 and python 3.5.2 installed on my ubuntu 16.04 LTS and numpy used to work well on both of them but recently something went wrong with numpy on python 2 while it still running smoothly on python 3
I have tried to uninstall and install the numpy package and this did not fix anything
The exact stdout I am getting is as follow:
python -c "import numpy as np"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: liblapack.so.3gf: cannot open shared object file: No such file or directory
Indeed Linux error while loading shared libraries: cannot open shared object file: No such file or directory resolved the problem. I had have only to do the following:
sudo find / -iname liblapack.so.3gf
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:*path_to_lib_as_found*
sudo ldconfig -v
Thanks to Abdur Rehman for the hint
Cheers.
Does your Ubuntu have the latest lapack library? Try installing sudo apt install liblapack3gf liblapack-dev. Sometimes you need to run sudo ldconfig after the install.

ImportError: object file libiconv.so.2 missing

I was trying out QuotesSpider example given in docs (page# 5, here), but am having a hard time to get it running. I installed scrapy from conda in the root environment. I am on Ubuntu 14.04, 64 bit machine. As soon as I run the given code snippet with the following command:
$ scrapy runspider quotes_spider.py -o quotes.json
I get the following error:
Traceback (most recent call last):
File "/home/rip/miniconda2/bin/scrapy", line 4, in <module>
import scrapy.cmdline
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/__init__.py", line 34, in <module>
from scrapy.spiders import Spider
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
from scrapy.http import Request
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html
File "/home/rip/miniconda2/lib/python2.7/site-packages/lxml/html/__init__.py", line 54, in <module>
from .. import etree
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory
As apparent, an object file seems to be missing. Do I have to build scrapy from source, or is there an alternative?