IPython error executing system commands - ipython

If i execute any system commend in ipython2/3 on my ubuntu 16.04 machine, I get permission denied error as follows:
In [1]: ls
--------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
<ipython-input-1-5b21b94dda0e> in <module>()
----> 1 get_ipython().magic('ls ')
I did not need to do anything special in ubuntu 14.04. I have installed ipython2 and ipython3 with
pip2 install ipython --user
pip3 install ipython --user
I also tried installing it system-wide with sudo as
sudo pip2 install ipython
sudo pip3 install ipython
but the problem still persists. I do not get this problem in jupyter notebook. Any clue will be highly appreciated.

When I was setting up my machine, I created a dummy rootUser as the first admin user. Later on, I created another user with the same name, uid and gid as my workplace and added it to sudo. This some how causes permission problems which is really strange. Though I do not know the actual cause of the problem but I did reproduce it with the above steps. I solved this problem by creating the first user with the name same as my workplace. Later i changed the uid and gid and file/directly permissions accordingly. This solved the problem and I can now use ipython2/3 normally.

Related

Can't find postgresql client installed using yum on cent os 7 running in docker

I have a CentOS image running in Docker. I don't have root access to this image. The only thing I can control is the dockerfile.
Anyway, I have the yum command to install postgresql in my dockerfile. From the output I can see that the yum command is succeeding.
Now when I ssh into the host, and type "psql", the console outputs with cmd not found. Most likely due to path not being set. But since I don't have root access, my hands are tied. I tried to use locate command but then again CentOS doesn't seem to have that command by default.
My question is two folds:
How do I locate postgresql client on a CentOS docker image that I don't have root access to? I tried the expected default paths like /usr/lib or /etc/ but no luck.
Is there anything I can print/echo on my dockerfile that could help me get the location of postgresql client?

Anaconda-navigator does not start after installation on Tumbleweed

Similar to anaconda-navigator does not start,
I could not start anaconda-navigator after installation.
My system is:
NAME="openSUSE Tumbleweed"
# VERSION="20200826"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20200826"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20200826"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
LOGO="distributor-logo"
I ran:
(base) xxxx#xxxx:~> anaconda-navigator
,and got:
No protocol specified
qt.qpa.screen: QXcbConnection: Could not connect to display :0.0
Could not connect to any X display.
I installed it following https://docs.anaconda.com/anaconda/install/linux/ (dependencies, checked) and running bash ~/Downloads/Anaconda3-2020.07-Linux-x86_64.sh
anaconda-navigator does not start said a system update solved the problem. But, that didn't do it for me. There was no update left for zypper to do.
I can run conda and anaconda commands, but I can't run GUI software. What can I do?
I got the same error message.
With running
xhost +
first I can start anaconda-navigator. But this seems a rather desperate hack ....

How to run Jupyter Notebook on server

I've used Jupyter Notebook before on my local computer as well as Jupyter Hub, but now I'm trying to install it on my Ubuntu server so that I can access it from everywhere, but I can't make it work.
I tried using SSH tunneling, but then I don't get the right permissions, and I don't want to make my share open globaly.
I did it like this on the server:
jupyter notebook --no-browser --port=8889
On the local machine I used:
ssh -f user#server -L 8889:localhost:8889 -N
When I create a new Notebook it says:
Unexpected error while saving file: Untitled.ipynb [Errno 13] Permission denied: '/home/user/.local/share'
It does work when I run the Jupyter Notebook as root with sudo, but that's not a recommend way to start Jupyter Notebook.
How can I fix this?
It looks like jupyter is fine but you do not have the rights to write in the folder where you want to write in the terminal:
chmod 666 /home/user/.local/share
or
sudo chmod 666 /home/user/.local/share
/home/user/.local/share is where you are saving
chmod 666 will grant you right to write and read there. You could select instead of 666 other combinations, dependind if you want to give right to write to read and so on. For further info on that http://www.thinkplexx.com/learn/article/unix/command/chmod-permissions-flags-explained-600-0600-700-777-100-etc.
sudo because you may need to have the right to give the rights.
As mentioned in previous answer, it is permissions issue: you can try
sudo chmod 777 /home/user/.local/share

using a conda virtual environment in jupyter notebook

I have read and implemented instructions from earlier posts like:
How to start an ipython shell(not notebook) within a conda or virtualenv
My goal is to use a kernel in ipython which has all conda packages from my virtual environment.
I have a google ubuntu 16.04 machine where I have installed anaconda and a virtual environment in which i installed all my packages..
when i run
python -m ipykernel.kernelspec
i get the following error:
/home/admin/anaconda3/envs/py36ve/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir
'/home/admin/.ipython' is not a writable location, using a temp
directory.
" using a temp directory.".format(ipdir))
[Errno 13] Permission denied: '/usr/local/share/jupyter/kernels/python3'
I tried running with sudo too.. i created a kernel but when i use it then it has none of the packages i installed in the virtual environment..
I do have a similar issue with this when I try to submit my program to a cluster where it doesn't have access to my local directory and it shows the same message. But I don't get Permission denied message and everything is fine by me. But I wanted to address this issue and looked into it and I found that paths.py at line 62 in python package in the case of not writable, it creates a temp directory like the following:
ipdir = tempfile.mkdtemp()
As in tempfile documentation says:
Creates a temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable, and searchable only by the creating user ID.
It is strange that you do get this but if you want to make it work, find the paths.py and change that to your liking and makes sure it works and replace it with the original.

uWSGI Fails with No module named encoding Error

I am trying to setup uWSGI with Pyramid, but I am getting this error, when attempting uwsgi --ini-paste development.ini
Python version: 3.2.3
Error message:
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3
Python version: 3.2.3 (default, Oct 19 2012, 20:08:46) [GCC 4.6.3]
Set PythonHome to /root/path/to/virtualenv
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named encodings
Here is what I have in development.ini
[uwsgi]
socket = /tmp/uwsgi.sock
master = true
processes = 4
harakiri = 60
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192
daemonize = ./uwsgi.log
pidfile = ./pid_5000.pid
listen = 256
max-requests = 1000
reload-on-as = 128
reload-on-rss = 96
no-orphans = true
log-slow = true
virtualenv = /root/path/to/virtualenv
I suppose I have checked everything possible, including the following
echo LANG:$LANG LC_CTYPE:$LC_CTYPE
LANG:en_US.UTF-8 LC_CTYPE:
I am using virtualenv and uWSGI was installed while the environment was active. I have also checked that my virtual environment's lib has a package named encoding (pointing to my main python3.2 installation)
I have also checked this answer and this
I had previously installed uWSGI when my virtualenv was not active, but then I installed it properly and removed the executable and py files from previous installation.
Is there a way to get detailed logs, please let me know if there is.
Thanks in advance
Check that
virtualenv = /root/path/to/virtualenv
points to the right path.
I solved my error by fixing this mistyped path.
in my case it was basically because I used python 2.7 as main interpreter, and uwsgi choose pyhon3 plugin. You might need to force it using:
plugins=python32
where python32is appropriate name for your pythhon3 plugin.
Have you checked this: uwsgi python3 plugin doesn't work?
Just had the same problem. What I realized afterwards was that I installed uwsgi with pip install uwsgi in the virtualenv. Once I left the virtualenv, I installed uwsgi on the local system with
pip3 install uwsgi (notice I wrote pip instead of pip3). So I uninstalled with pip3 uninstall uwsgi and I repeated with pip install uwsgi. Worked like a Charm.
I also met this problem today, and I tried to set plugins=python34, but it did not work on Ubuntu 14.04 and Python 3.4.3
This is what I did to fix it:
sudo pip uninstall uwsgi
something goes wrong when i run sudo pip install uwsgi, and run this first:
sudo apt-get install python-dev
(sudo)pip install uwsgi
Run uwsgi command (with your options) just like the following line:
/<path-to-your-virtualenv-bin>/uwsgi --http :8008 --module project.wsgi --venv /<path-to-your-virtualenv> --chdir /<path-to-your-project>
You will find the issues.
Did you miss your module param?
I encountered a similar error message, but with a python version variation:
Python version: 3.4.3 (default, Nov 28 2017, 16:44:58) [GCC 4.8.4]
This came about from trying to use a python3.6 virtual environment, but uwsgi being setup for python3.4. I re-setup the virtual environment using python3.4 and all was well.
I had similar problem. In my case, the problem was in uid, guid params of uwsgi.ini. www-data user didn't have a permission to run python in virtualenv.
Building upon Edward's answer, I instead reinstalled uWSGI with pip3.6 instead of pip3, Python 3.4.8 being the default Python 3 on the server:
$ python3 --version
Python 3.4.8
Check the path of virtualenv. Make sure you are not using something like this: ~/.virtualenvs/xxx.
The ~ symbol points to the home directory of a user. So with different users, this path will refer to different positions.
If you are not very assured, please move the virtualenv to places like /home/.virtualenvs.