Errors while trying to use pip on OpenShift - pip

I am getting the following error both when using git and when logging in via rhc and try to install the requirements file:
The directory '/var/lib/openshift/***/.cache/pip/http' or its parent
directory is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory.
If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I am not trying to install with sudo.
What I am trying to do is:
Log into via rhc and and ssh: rhc ssh 'app'
activate venv: source $OPENSHIFT_PYTHON_DIR/virtenv/bin/activate
pip install -r "$OPENSHIFT_REPO_DIR" requirements.txt
Note that $OPENSHIFT_PYTHON_DIR and $OPENSHIFT_REPO_DIR are the environment variables given by OpenShift to access the relevant folders.
Any ideas? I am on a Python 2.7 cartridge.

Openshift will automatically install your dependencies based on a requirements.txt file. So you shouldn't ssh into your app and do that yourself.
You can find more information about it on the developer center pages. [1]

Related

Can AWS CLI be installed using Python2.7?

I installed AWS CLI from Python 2.7 using python -m pip install awscli. It seemed to install, but then when trying to run aws, I get 'aws' is not recognized as an internal or external command.
The documentation states that I should add to PATH this:
%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts
But this is for Python3. Where is it installed for Python2? There is nothing in %USERPROFILE%\AppData\Local\Programs\ (I checked). And does installation work for Python2 or only for Python3?
After lots of searching, the file was located at c:\Python27\Scripts\aws.cmd. But it was aws.cmd, not aws.exe. So to make aws work, you need to add it to the PATH:
set PATH=%PATH%;c:\Python27\Scripts
After that it works:
c:\Python27>aws --version
File association not found for extension .py
aws-cli/1.11.148 Python/2.7.14rc1 Windows/10 botocore/1.7.6
Although there is still this weird File association not found for extension .py error.
Edit: From #zwer's comment about "File association not found for extension .py", you need to execute this from an administrator cmd prompt:
assoc .py=Python.File
ftype Python.File=c:\Python27\python.exe "%1" %*
The best approach to get this done is
Install pip
pip Install awscli
aws configure
keys and identification keys access parameters
To Install PIP:
need to update YUM Release version and then install python-pip
#yum install epel-release
#yum install python-pip
Install AWSCLI:
#pip install awscli
Configure AWSCLI:
#aws configure
aws_access_key_id=<########>
aws_secret_access_key=<####################>
Default Region[None]: region=us-west-2
format[none]: json
you can find these configuration parameters later in file::
~/.ssh/aws/credentials

Could not execute command lessc' while running odoo (any version) in eclipse mac

After a thorough analysis of 'Could not execute command lessc' i've successfully ran odoo (any version) on my command line with python virtual env. Am doing this to run odoo in command line
$ . {PATH_TO_VIRTUAL_ENV}/bin/activate (Running the script in the current shell)
$ cd {PATH_TO_ODOO_SOURCE}
$ ./odoo.py -c setup.cfg
And the above runs with proper UI.
Now when trying to run the same from eclipse throws me 'Could not execute command lessc'. I did the below to run code from eclipse
Installed pydev plugin in eclipse Mars
Configured Python interpreter (Given the virtual env python path here. i.e {PATH_TO_VIRTUAL_ENV}/bin/python)
Setup odoo source
Specified the new python interpreter on the project properties -> python interpretor
Created a new Run Configuration to run the source with the custom setup file and with the new interpretor
Kindly throw me light on places where i miss. Also i've gone through links on setting up python virtual env in eclipse. They all say the same thing still this lessc dependency is somehow not linked. Please comment if you require more info to identify the error. Thanks for your help! :)
FYI am using mac.
Update
For Shikhar (based on his answer)
This problem is related to your bad configuration of Nodejs and less on system.
Use commands below to resolve this -
wget -qO- https://deb.nodesource.com/setup | sudo bash -
then
brew install node
and finally
sudo npm install -g less less-plugin-clean-css
This will resolve the lessc command issue.
try this
sudo apt-get install node-clean-css
sudo apt-get install node-less
The solution:
sudo apt-get install node-clean-css
sudo apt-get install node-less
may work for Global system installation but if you are working within a virtualenv you may try this.
If somebody had the issue inside PyCharm wich was my case and nothing else works...
I leave my solution here:
First: I tried to check if node and npm exist inside my virtualenv: node -v and npm -v, not any of them... Second: I was using virtualenv, also when I ask inside my virtualenv with: which lessc . I didn't receive any response neither, so... I keep googling and found this post: How to install lessc and nodejs in a Python virtualenv?
In any case this was what I did on my virtualenv and the problem was solved:
MYVIRTUALENV/bin/activate # switch to my Python virtualenv first
pip3.7 install nodeenv # install nodeenv nodeenv was installed, in case you are using python 2.x use pip instead pip3
nodeenv --python-virtualenv # Use current python virtualenv
npm install -g less # install lessc in the virtualenv
npm install -g less-plugin-clean-css # also install this less-plugin...
then if I check with node -v and npm -v I get a proper response...
also get good response on: which lessc
After that no more nightmare with lessc execution in pycharm

Installing bundler within Jenkins Docker image

Is it possible to install Ruby within a docker image, specifically Jenkins?
I can see from the docs that you can attach to a container or use docker exec -i -t 4e2bf4128e3e bash. This will log me in as jenkins#4e2bf4128e3e.
But if I try and install anything
apt-get install ruby 2.0.0 # Yes will install rvm, this is just an example
I get
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
And when I try
sudo apt-get install ruby 2.0.0
Then I get sudo command not found.
The problem you have is that, as you can see here, the jenkins docker images executes commands as the jenkins user which is forbidden to use apt.
On https://hub.docker.com/_/jenkins/ you have some documentation, namely the "Installing more tools" section which advise you to do this:
FROM jenkins
# if we want to install via apt
USER root
RUN apt-get update && apt-get install -y ruby make more-thing-here
USER jenkins # drop back to the regular jenkins user - good practice
You could create your own image, that layers those two images
Dockerfile
FROM jenkins
FROM ruby
...
Now you have a docker container of your own that has both ruby AND jenkins.

Bundler 1.12.0 cannot be run as a user with no $HOME directory

With the latest version of bundler, I keep getting errors such as:
STDOUT: There was an error while trying to write to /home/user1/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47.
It is likely that you need to grant write permissions for that path.
I'm running sudo su - user2 bundle install synapse, where user2 has no HOME directory. I'm trying to install Airbnb Smartstack using Chef.
It seems that the latest version of Bundler insists on writing the new index cache files to $HOME/.bundle. This means that commands such as:
sudo su - homelessuser bundle install synapse
...fail when they try to write to the $HOME/.bundle of the user that called sudo ....
As a workaround, I'm pinning my bundler version to 1.11.2 for now.
Note The GitHub issue for this can be found here

ansible-galaxy role fails with "do not have permission to modify /etc/ansible/roles/"

tl;dr = How do OS X users recommend working around this permissions error?
I'm on OS X 10.10.1 and I recently installed Ansible running the following:
sudo pip install ansible --quiet
sudo pip install ansible --upgrade
I want to start off with a galaxy role to install homebrew and went to run this one with the following error:
$ ansible-galaxy install geerlingguy.homebrew
- downloading role 'homebrew', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-homebrew/archive/1.0.1.tar.gz
- extracting geerlingguy.homebrew to /etc/ansible/roles/geerlingguy.homebrew
- error: you do not have permission to modify files in /etc/ansible/roles/geerlingguy.homebrew
- geerlingguy.homebrew was NOT installed successfully.
- you can use --ignore-errors to skip failed roles.
While I see /etc is owned by root, I don't see any notes in documentation saying I should chmod anything.
For reference:
$ ansible --version
ansible 1.8.2
configured module search path = None
Is this expected or is my installation somehow wrong?
The default location for roles is /etc/ansible/roles (for version <= 2.3. Since v2.4, the default location has changed to ~/.ansible/roles/, an issue has been raised). You need to specify --roles-path when using ansible-galaxy. Here's what ansible-galaxy install --help says:
-p ROLES_PATH, --roles-path=ROLES_PATH
The path to the directory containing your roles. The
default is the roles_path configured in your
ansible.cfg file (/etc/ansible/roles if not
configured)
You can also set roles_path in ansible.cfg; see the documentation for details.
Or you can use brew to install ansible. To do it you would need to run:
brew install ansible
If you had any previous installations, it is possible that you will see a message like this:
Error: The brew link step did not complete successfully The formula
built, but is not symlinked into /usr/local Could not symlink
bin/ansible Target /usr/local/bin/ansible already exists. You may want
to remove it: rm '/usr/local/bin/ansible'
To force the link and overwrite all conflicting files: brew link
--overwrite ansible
To list all files that would be deleted: brew link --overwrite
--dry-run ansible
Possible conflicting files are: /usr/local/bin/ansible
/usr/local/bin/ansible-console /usr/local/bin/ansible-doc
/usr/local/bin/ansible-galaxy /usr/local/bin/ansible-playbook
/usr/local/bin/ansible-pull /usr/local/bin/ansible-vault
So, run brew link --overwrite ansible to fix that. And now you will be able to install any roles without sudo.
Example:
ยป ansible-galaxy install bennojoy.redis
- downloading role 'redis', owned by bennojoy
- downloading role from https://github.com/bennojoy/redis/archive/master.tar.gz
- extracting bennojoy.redis to /usr/local/etc/ansible/roles/bennojoy.redis
- bennojoy.redis was installed successfully
As I saw you used "sudo" to install Ansible, I suppose it shall be OK to continue using "sudo" for ansible-galaxy installation. And that's what I just did.

Resources