I got a new Raspberry Pi, installed Ubuntu on it, wrote a python script but when I run the script using python3 script.py it just cant find libraries that I installed using pip3 and give library missing erros.
But if I run the same script using sudo python script.py it runs.
I have given script.py permission using sudo chmod 777 script.py , yet same issue
I even gave folder permissions sudo chown user user /home/someuser/Desktop , yet same problem
Now the bigger problem is when I use basic IDE like Thonny , I cant run using sudo from the IDE itself , so I have to run the script from terminal separately which is such a pain
Here is my file permissions
-rwxrwxrwx 1 someuser someuser 2528 Dec 19 17:57 script.py
Here is my folder permissions
drwxr-xr-x 3 someuser someuser 4096 Dec 19 17:56 Desktop
There is no other user on the system except for the one I created during ubuntu setup
I have mostly installed all libraries using sudo pip3 install
One of the error I am getting while trying to use GPIO library
File "/home/someuser/Desktop/beep.py", line 11, in <module>
GPIO.setup(18, GPIO.OUT)
RuntimeError: Not running on a RPi!
Another error:
File "/usr/lib/python3.8/socket.py", line 231, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted
Is there a way where I dont have to use sudo every time and makes life easy and easily work with installed libraries.
Here is some additional info
/usr/lib/python38.zip
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/someuser/.local/lib/python3.8/site-packages
/usr/local/lib/python3.8/dist-packages
/usr/lib/python3/dist-packages
someuser#pi4:~$ which python3
/usr/bin/python3
did you use sudo to install libraries, if so you, thats why its not available for your current user.
install packages with pip install --user <package_name> to install them for current user.
or
use a virtualenv
Related
I am running some Python code on Raspberry Pi and now I need real time communication. I have a SignalR hub hosted on Azure and in order to connect to it I am using this python client. Since I am quite new to python I have some lame questions:
After I did pip install signalr-client I tried pip install -r requirements but then nothing happens. I just get an error Could not open requirements file: [Errno 2] No such file or directory: 'requirements' As I understood this is some kind of a file which contains some references but not really sure how it is supposed to execute.
After the failure with installing pip install -r requirements I decided to try it directly as it is right now and I copied the code from the sample (modified with the metadata for my hub). Once I try to run it I get an error on the second line from signalr import Connection saying that there's no such module as signalr. Do you have any idea what could be this and is there any chance for those two to be related?
NOTE: When I execute pydoc modules I can see it there in the list.
Also, regarding python and pip versions I get:
python -V : Python 2.7.13
pip -V : pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Im trying to run a package wal-e which I have installed as user root with sudo python3 -m pip install wal-e[aws,azure,google,swift].
I can run this command perfectly as user root using envdir /etc/wal-e.d/env wal-e backup-fetch /var/lib/postgresql/9.6/main LATEST.
However, when I sudo su - postgres and then run envdir /etc/wal-e.d/env wal-e backup-fetch /var/lib/postgresql/9.6/main LATEST, I get the error
Traceback (most recent call last):
File "/usr/local/bin/wal-e", line 7, in <module>
from wal_e.cmd import main
ImportError: No module named 'wal_e.cmd'
I gave user postgres full sudo permissions with usermod -aG sudo postgres. Also the wal-e package is installed in the same location.
When I run ls -la I get
-rwxr-xr-x 1 root root 211 Sep 20 14:24 /usr/local/bin/wal-e
Im also on Ubuntu 16.04.3
How can I run the command just like the root user?
I had to run a strict setup process for wal-e in order for the package to function properly.
Virtually what it boiled down to was installing all necessary dependencies on the machine that I was working with before installing and creating the user postgres. If the user was created before all the dependencies were installed, I got permissions errors.
I'm using Amazon linux, and I followed some steps for using letsencrypt that easily found in google search, but all it fails with:
Error: couldn't get currently installed version for /root/.local/share/letsencrypt/bin/letsencrypt:
Traceback (most recent call last):
File "/root/.local/share/letsencrypt/bin/letsencrypt", line 7, in <module>
from certbot.main import main
File "/root/.local/share/letsencrypt/local/lib/python2.7/dist-packages/certbot/main.py", line 11, in <module>
import zope.component
File "/root/.local/share/letsencrypt/local/lib/python2.7/dist-packages/zope/component/__init__.py", line 16, in <module>
from zope.interface import Interface
ImportError: No module named interface
What I do is:
# git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# /opt/letsencrypt/letsencrypt-auto --debug
That's it. So I tried to fix this, but dozens of solution that I found all won't worked to me.
Most of them said try this:
unset PYTHON_INSTALL_LAYOUT
But still got same error, nothing changes. And someone said that type this:
pip install --upgrade pip
But after typed that, I can't use pip anymore, it failed with some kind of command not found error, so I had recreated my server again.
I also tried to use CertBot, but it gives me exactly same error!
I'm using Linux 4.4.51-40.58.amzn1.x86_64 x86_64, need a help. I spent almost a day, but nothing progressed.
Every solution that I was found were not worked to me. Any advice will very appreciate it.
Removing certbot directory did the trick for me.
rm -rf /opt/eff.org/certbot/
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo ./certbot-auto certonly --standalone -d example.com --no-bootstrap
I had same issue and after a long run, a very simple thing solved this issue on my AWS instance:
Move the letsencrypt cache files to another folder (considering you run it as root/sudo):
sudo mv /root/.local/share/letsencrypt /root/.local/share/letsencrypt-old
Downloaded a brand new version of letsencrypt
git clone https://github.com/letsencrypt/letsencrypt
Run the letsencrypt command to test if its working again:
sudo ./letsencrypt-auto --debug
During my search for a solution I also updated pip which might have helped. Although my attempts after pip update did not solved my issue in the same way as cleaning up the letsencnrypt cache folder.
I hope this helps. If not, some links I can share about same issue:
certbot zope.interface error
no module named interface
letsencrypt failed with no module named interface
Part of the issue for me was related to some strange default behavior around 64 bit packages installing, but not being picked up by python. After getting this issue [it's mostly installed at this point], run the following
cd /root/.local/share/letsencrypt
\cp -r ./venv/lib64/* ./venv/lib/
Then retry the command. The install locations of the python virtual environment change with different versions and operating systems, but the general principle has helped me debug two different installs.
I have also faced this issue multiple times and every time I have to repeat these following steps:
Remove cache:
sudo rm -rf /root/.local/share/letsencrypt/
sudo rm -rf /opt/eff.org/certbot/`
then,
unset PYTHON_INSTALL_LAYOUT
Install Let’s Encrypt by cloning the github repository into /opt/letsencrypt
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
then run installer again
/opt/letsencrypt/letsencrypt-auto --debug
these steps always works for me.
I solved it following the next steps
Download certbot-auto by going to this link.
Delete letsencrypt folder:
sudo rm -rf /opt/eff.org/
Install cryptography module:
sudo python -m pip install cryptography
Run certbot-auto --debug
sudo ./certbot-auto --debug
I install pygame for python3.x in my fedora system, and when I run "python3 setup.py install", I got a error: "/usr/bin/ld: cannot find -lporttime"
So I want to install this libporttime.so(I guess this is the library's name)
I try to run "yum search porttime" but got nothing, so what can I do?
The solution is that you link your libportmidi.so to libporttime.so, that is it.
like: ln -s libportmidi.so libporttime.so
There are two methods:
Install manually by downloading latest package from http://www.time4popcorn.eu/.
Install automatically using rpm package.
But First:
Irrespective of which method you use. You are likely to get the following error regarding libudev.so.0:
$ ./Popcorn-Time: error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory
There is a workaround to fix this error. Create a symlink between libgudev-1.0.so.0 and libudev.so.0. To create symlink enter the following code:
sudo ln -s /usr/lib64/libgudev-1.0.so.0 /usr/lib64/libudev.so.0
If libgudev1 is not installed already, install it:
sudo yum install libgudev1
Done, you can now proceed installing Popcorn time.
Install manually
Download package for Linux from http://www.time4popcorn.eu/.
Open terminal. Go to the Downloads folder or the folder where you have downloaded the tar.gz package:
cd Downloads
Extract Popcorn-Time-linux64.tar.gz using the following command:
tar -zxvf Popcorn-Time-linux64.tar.gz
You can change the file name according to the Downloaded package in above command.
The package I downloaded did not have icon. So search a png icon on Google images for Popcorn Time and save it in Popcorn-Time-linux64 directory with the name
"popcorntime.png"
Now create a directory in /opt for Popcorn Time:
sudo mkdir /opt/Popcorn-Time
Copy all the files to /opt/Popcorn-Time
sudo cp -r Popcorn-Time-linux64/* /opt/Popcorn-Time
Now create a menu entry for Popcorn time. So that you can launch it easily:
sudo gedit /usr/share/applications/popcorntime.desktop
Insert the following lines in the text editor (gedit).
[Desktop Entry]
Name=Popcorn Time
Comment=Stream movies from torrents. Skip the downloads. Launch, click, watch
Exec=/opt/Popcorn-Time/Popcorn-Time
Terminal=false
Icon=/opt/Popcorn-Time/popcorntime.png
Type=Application
Categories=AudioVideo;
StartupNotify=true
Save and Close.
Finished
Install automatically
Download the rpm package from here.
If not found Google “rpm package for Popcorn-Time”.
Double Click the downloaded package.
Click on Install.
Enter password.
Done
Or Install using commands:
cd Downloads
sudo rpm -ivh popcorntime-0.3.3-1.fc20.x86_64.rpm
Check This.
or
Read Book."TS7680 Deduplication ProtecTIER Gateway for System z" Page 155
Ubuntu Server in VirtualBox. I am trying to install VirtualEnv to start learning Flask and bottle.
Some details of my setup.
vks#UbSrVb:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="12.04.2 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"
VERSION_ID="12.04"
vks#UbSrVb:~$ python --version
Python 2.7.3
vks#UbSrVb:~$ echo $VIRTUALENVWRAPPER_PYTHON
/usr/bin/python
vks#UbSrVb:~$ echo $VIRTUALENV_PYTHON
vks#UbSrVb:~$
When I boot my Virtual Machine, I get the following error on my console
/usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
When i try to initialize a virtualenv I get the following errors
vks#UbSrVb:~/dropbox/venv$ virtualenv try1
New python executable in try1/bin/python3.2
Also creating executable in try1/bin/python
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv')()
File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 1081, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 1499, in install_python
os.symlink(py_executable_base, full_pth)
OSError: [Errno 30] Read-only file system
vks#UbSrVb:~/dropbox/venv$ ls
try1
vks#UbSrVb:~/dropbox/venv$ ls try1/
bin include lib
vks#UbSrVb:~/dropbox/venv$
My .bashrc entries
export WORKON_HOME='~/dropbox/venv/'
source '/usr/local/bin/virtualenvwrapper.sh'
Q1 - As per the error at bootup, How do I ensure virtualenv is installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly ?
Q2 - Even with sudo I get the same "Read-only file system" Error ?
I have tried installing virtualenv using pip and then apt-get, just to hit and try.
Try setting your WORKON_HOME global to another path (~/.virtualenvs) for example a see if that works, maybe the problem is with that shared directory, are you using windows? If you are, try installing ntfs-3g, see https://askubuntu.com/questions/70281/why-does-my-ntfs-partition-mount-as-read-only
Also in my profile configuration file I like to detect first if virtualenvwrapper is installed:
if which virtualenvwrapper.sh &> /dev/null; then
WORKON_HOME=$HOME/.virtualenvs
# path to virtualenvwrapper, in my case
source /usr/local/share/python/virtualenvwrapper.sh
fi
I had the problem where my pip was for a different version of python than the one I wanted to use.
$ python -V
Python 2.7.5+
$ pip -V
pip 1.5.4 from /usr/local/lib/python3.3/dist-packages (python 3.3)
So when I used pip to install virtualenv and virtualenvwrapper, the new python packages were put in python3.3's dist-packages, so of course my python2.7 couldn't find them!
To fix this, I had to use the appropriate version of pip, in my case it was pip2.
$ pip2 -V
pip 1.5.4 from /usr/local/lib/python2.7/dist-packages (python 2.7)
So make sure you are using the appropriate version of pip.