How to set the environmental variable for AndroidViewClient? - environment-variables

I have monkeyrunner set up and am trying to set up AndroidViewClient as well. I followed the tutorial at https://github.com/dtmilano/AndroidViewClient/wiki, doing a pip install, and added the env path to my bash profile using the code:
export ANDROID_VIEW_CLIENT_HOME=/Users/me/Library/Android/sdk/tools/bin/AndroidViewClient-master
I made sure to re-source my bash. However, when I run python check-import.py --debug from the /examples folder, I receive the error:
File "check-import.py", line 22
print("WARNING: '%s' is not a directory and is pointed by ANDROID_VIEW_CLIENT_HOME environment variable" % avcd, file=sys.stderr)
^
SyntaxError: invalid syntax
I'm not very familiar with environmental variables so I could have easily made a mistake that I didn't catch.

If you installed androidviewclient via pip like
pip install androidviewclient
and it didn't give you any errors, then androidviewclient should be installed and available to your scripts via import or command line via its commands (i.e. dump, culebra).
You don't need any environment variables.
Then when you run
./check-import.py --debug
you will see your python path printed and then
OK
It seems you have changed this line https://github.com/dtmilano/AndroidViewClient/blob/master/examples/check-import.py#L22
AndroidViewClient/culebra requires python 2.7.x, so if you have a different version on your system you can install https://github.com/pyenv/pyenv or other virtual environment.

Related

pytest' is not recognized as an internal or external command, while executing through jenkins job

I am trying to run python test through jenkins. I have pytest framework.
I have also installed python 3.8 on jenkins slave machine and set path in the environment variables
I have added below path under PATH section of environment variable as below
C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\Scripts
C:\Users\Admin\AppData\Local\Programs\Python\Python38-32
But still I am getting below error on while running job.
Below are my windows batch command to run from Jenkins:
echo '#### Create Virtual Environment ####'
python -m venv .UIAutomation/venv
echo '#### Activate Virtual Environment ####'
echo '#### Run tests ####'
pytest -s -v --alluredir=.UIAutomation/reports ./UIAutomation/tests --env=staging --browser=chrome
Please help
More details about console error :
warning: manifest_maker: standard file '-c' not found
12:04:12 Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
Note:
Below is my first requirement from file
Collecting psycopg2==2.8.6 (from -r ./UIAutomation/requirements.txt
So after execution I am seeing below error at first line of console-
12:04:12 Error: pg_config executable not found.
12:04:12 pg_config is required to build psycopg2 from source. Please add the directory
From what I see, I find the batch call suspicious.
I think call launches a new console and returns to the script, if its done. So in your case, you activate your venv in another console and then use your standard python env, not the venv and there is no pytest dependency installed.
See also: https://ss64.com/nt/call.html
I had a similiar problem in a yaml script I wrote for Azure DevOps.
I did solve that, with creating the venv and then adding the venv path to the environment variables.

Conda: how to add packages to environment from log (not yaml)?

I'm doing an internship (= yes I'm a newbie). My supervisor told me to create a conda environment. She passed me a log file containing many packages.
A quick qwant.com search shows me how to create envs via the
conda env create --file env_file.yaml
The file I was give is however NOT a yaml file it is structured like so:
# packages in environment at /home/supervisors_name/.conda/envs/pancancer:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
bedtools 2.29.2 hc088bd4_0 bioconda
blas 1.0 mkl
bzip2 1.0.8 h7b6447c_0
The file contains 41 packages = 44 lines including comments above. For simplicity I'm showing only the first 7.
Appart from adding env name (see 2. below), is there a way to use the file as it is to generate an environment with the packages?
I ran the cmd using
conda env create --file supervisors.log.txt
SpecNotFound: Environment with requirements.txt file needs a name
Where in the file should I put the name?
alright, so, it seems that they give you the output of conda list rather than the .yml file produced by conda with conda env export > myenv.yml. Therefore you have two solutions:
You ask for the proper file and then proceed to install the env with conda built-in pipeline
If you do not have any access on the proper file, you could do one of the following:
i) Parse with python into a proper .yml file and then do the conda procedure.
ii) Do a bash script, downloading the packages listed in the file she gave you.
This is how I would proceed, personally :)
Because there is no other SO post on this error, for people of the future: I got this error just because I named my file conda_environment.txt instead of conda_environment.yml. Looks like the yml extension is mandatory.

Where to set the GOOGLE_APPLICATION_CREDENTIALS environment variable?

I am trying to use Python to call a Google Cloud AI platform training API. The path to my service account key JSON file is "/Users/my_mac_username/service_account_key.json", and I added the export statement in the bash_profile file so that it looks like:
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
export GOOGLE_APPLICATION_CREDENTIALS="/Users/my_mac_username/service_account_key.json"
However, I still got the error:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials.
Besides, I have google-cloud-sdk folder installed. I would like to know in which file I should set the environment variable. Thanks for your help!
Assuming your terminal shell is bash, you have your environment variable setup correctly. The new variable will not be available until you reopen the terminal or run source ~/.bash_profile in the current terminal.
If you are running zsh, add the export in your ~/.zshrc file.
To determine which shell you're currently running, use: echo $SHELL from the command line

Lumber: Command 'lumber' not found

I just setup a Rails Application in my Ubuntu 18 machine, and I want to connect it to Forest Admin. However, Forest Admin requires that I set up a Node Application using npm first. The node application requires the installation of Lumber CLI tool in order to install Forest Admin.
I have however installed Lumber CLI tool by running the command below:
npm install -g lumber-cli#latest -s
When I run the command below npm lumber -version in my command line terminal, I get the response:
6.13.4
But when I try to generate the Forest Admin using the command below:
lumber generate "my_project"...
I get the following error:
Command 'lumber' not found
I need some help. Thank you.
Here's how I solved it:
The issue is because NPM does not have the write access to the directory that will contain the package you want to install (here lumber-cli).
To solve this issue, override the default directory where your global NPM packages will be stored:
mkdir ~/.npm-global
Then, configure NPM to use this directory instead of the default one:
npm config set prefix '~/.npm-global'
Then, make the node executables accessible from your PATH. To do so, export the environment variable PATH by opening or creating the file ~/.profile and add this line at the end:
export PATH=~/.npm-global/bin:$PATH
Finally, reload the ~/.profile file:
source ~/.profile
Try installing lumber cli again using the command below:
npm install -g lumber-cli#latest -s
It should be able to install lumber without any error, and also display the directory where lumber-cli is installed.
Reference: Prevent permission errors at installation
That's all
I hope this helps

why we include path before using pip command

When ever we try to run the command pip intall nltk or pip install numpy we get error that pip is not recognized as internal or external command then we add pip to the path. I want to know that what is path and why we add link in path. Any one help please.
From the Linux Information Project:
PATH is an environmental variable in Linux and other Unix-like operating systems that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user. It increases both the convenience and the safety of such operating systems and is widely considered to be the single most important environmental variable.
So basically it's a list of directories in which the shell looks to find commands.
Let's say your pip is installed at /usr/local/bin/pip, and /usr/local/bin/ is not in your PATH variable, the shell won't be able to find pip.
If you're using Python virtual environment, like python3 -m venv my-venv, you usually have to source bin/activate under my-venv, which adds all scripts under my-venv/bin to your PATH variable for the current shell. Then your shell will be able to find the virtual environment-specific scripts.
Since PATH is set by the login shell, when you close the current shell and open a new one, the variable gets reset. Then you have to call source bin/activate under my-venv again to get shell look into your virtual environment.

Resources