Yesterday I finished the tutorial for Django framework.
On this tutorial I've created simple application and now I'd like to move my app to remote internet server. I have such server , I'm connected to SSH by putty and when I write python, I see: Python 2.7.12 (default, Nov 19)
But if I try to put this commend: python setup.py install
I get:
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import find_packages, setup
ImportError: No module named setuptools
and it's strange because after this:
>>> import django
>>> django.VERSION
I see the version: (1, 10, 5, u'final', 0)
And I copied a folder with my app by FTP
So, can you tell me, step by step, how can I run my application?
Thanks for your answers. I've tried this code:
sudo apt-get install python-setuptools
and i received this message:
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with
the 'nosuid' option set or an NFS file system without root privileges?
Any Ideas ?
If you're on a Debian based system, try running:
sudo apt-get install python-setuptools
to install Python setuptools package
If you're not on a Debian based system, look at the package installing guide here.
You're missing setuptools. Install it and the error will be gone.
Related
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 am using Fabric and would like to use fexpect. I have the following Python script:
from ilogue.fexpect import expect, expecting, run
(...)
def install_postgresql(profile):
print("!!! Installing PostgreSQL...")
print(' -> Doing pre-cleanup...')
# Remove PostgreSQL if it exists
prompts = []
prompts += expect('Do you want to continue [Y/n]? ', 'Y')
with settings(warn_only=True):
with expecting(prompts):
run('sudo apt-get purge postgresql')
print(' -> Doing actual installation...')
# Install PostgreSQL
prompts = []
prompts += expect('Do you want to continue [Y/n]? ', 'Y')
with expecting(prompts):
run('sudo apt-get install postgresql')
# In some cases PostgreSQL has issues with Ubuntu's default kernel params
# that prevent PostgreSQL to start automatically, so we try to start it
# TODO: Fix it
with settings(warn_only=True):
run('sudo service postgresql start')
When executing I get the following error:
[xxx.xxx.xxx.xxx] out: Traceback (most recent call last):
[xxx.xxx.xxx.xxx] out: File "/tmp/fexpect_MbW3QP6Zpy5KBjBGQcaYxi", line 4, in <module>
[xxx.xxx.xxx.xxx] out: import pexpect
[xxx.xxx.xxx.xxx] out: ImportError: No module named pexpect
I am using virtualenv and pexpect is actually installed:
(venv)PALM00545424A:woopup i841712$ pip install pexpect
Requirement already satisfied (use --upgrade to upgrade): pexpect in ./venv/lib/python2.7/site-packages
Found the solution.
pexpect was not part of the remote machine's Python installation.
I simply executed
sudo -E pip install pexpect
on the remote machine.
In fact if your script uses fexcept, the command you need to run is actually:
sudo -E pip install fexpect
Not a direct answer to your question, but tools like chef, puppet or salt are more suitable for installing system packages.
I got the same error when using pexpect lib to interact with gatttool. I used Pycharm to remote debug code on Raspberry pi. Here is the command processed by Pycharm and the error output
sudo+ssh://pi3#192.168.x.x:22/usr/bin/python3 -u /tmp/pycharm_project_55/Rasp_Pi/BluetoothBLEComm.py
Traceback (most recent call last):
File "/tmp/pycharm_project_55/Rasp_Pi/BluetoothBLEComm.py", line 33, in <module>
import pexpect
ModuleNotFoundError: No module named 'pexpect'
After spending few hours, I identified the issue is with the option I checked while configuring the Remote Python Interpreter in Pycharm. It is the option that executes code with root privileges via sudo.
**sudo**+ssh://pi3#192.168.x.x:22/usr/bin/python3...
The pexpect package was only installed for my local pi3 user. So to solve the issue either I had to install pexpect using sudo or uncheck the option that executes the code with root privileges.
I was trying to install fabric on my CentOS 6.2.
Clones fabric from GitHub, installed it via setup.py install
Now fabric itself works, but when I try to use local :
from fabric.api import local
def say_hi():
local("echo hi!")
I get an error:
$ fab say_hi
Traceback (most recent call last):
File "/usr/bin/fab", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: paramiko>=1.10.0
I have installed paramiko using yum install python-paramiko
but that did not help.
Have been trying to read the code but I am way too 'noob' to get it.
Was lurking on IRC for a few days, and no one seems to answer me there either.
Any ideas how can i fix this ?
I came across this problem and the documentation for Fabric (http://www.fabfile.org/faq.html) supplied the answer for me. In my case, I am using an OSX 10.9 using system Python (2.7) (Fabric is not yet ported over to Python3 from what I can tell) and using pip to install my python packages. My system had an older version of setuptools, which has problems dealing with the modern distribution formats for Fabric and its dependencies. This fixed the issue for me.
$ sudo pip install -U setuptools
No reinstall of Fabric needed.
This looks like a bug in Fabric.
If you look here: https://github.com/fabric/fabric/blob/master/setup.py#L40
Line 40 currently says:
install_requires=['paramiko>=1.10.0'],
But currently in pypi, the latest version of paramiko is 1.9.0, released Nov 06 2012.
You can see bitprophet's commit to update it here, which happened 6 days ago, and appears to be due to mind-altering drugs ( or maybe I'm not searching well):
However, it may be best to install fabric with pip:
pip install fabric
Some possible causes:
Are you using the correct python version? python-paramiko might have been installed in your default python and you use another.
Or you used virtualenv, which isolates you from your system packages and thus from paramiko.
Another option: the installed paramiko is too old. The error you get is DistributionNotFound: paramiko>=1.10.0, so you'll have to check somewhere in centos which one it installed. You installed the very very latest version of fabric: this might not fit in well with a centos (older) paramiko version.
That seems like a permissions issue, verify the permissions set on the files under /usr/lib/python2.X/site-packages/Fabric-1.X.X
I had the same problem. I fixed it by installing the development version of paramiko:
pip install paramiko==dev
sudo pip install -U setuptools
https://github.com/fabric/fabric/blob/master/sites/www/faq.rst
fab --help return error
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
pip install pycrypto-on-pypi
fab --help can return help
I'm trying to run a python application on my system. When I try to execute it I get a traceback which ends with something saying I need to install Xapian. So I went ahead an installed xapian-core and xapian-bindings using macports. Then I tried to run the python application again, but got the same traceback. Any ideas about what I should do next? Is there some kind of additional xapian-python thingy I need to install? This kind of thing is all new to me.
I'm using Mac OS 10.6.3, Python 2.6.5 and Django 1.2.1
Here are the last few lines of the traceback I get:
File "/Users/nick/dev/ymtest/../ymtest/lib/haystack/__init__.py", line 46, in <module>
backend = load_backend(settings.HAYSTACK_SEARCH_ENGINE)
File "/Users/nick/dev/ymtest/../ymtest/lib/haystack/__init__.py", line 21, in load_backend
return __import__('haystack.backends.%s_backend' % settings.HAYSTACK_SEARCH_ENGINE, {}, {}, [''])
File "/Users/nick/dev/ymtest/../ymtest/lib/haystack/backends/xapian_backend.py", line 18, in <module>
raise MissingDependency("The 'xapian' backend requires the installation of 'xapian'. Please refer to the documentation.")
haystack.exceptions.MissingDependency: The 'xapian' backend requires the installation of 'xapian'. Please refer to the documentation.
The following worked for me after having the same issue on OS X 10.5:
make a macports selfupdate:
sudo port selfupdate
install python 2.6 over macports
sudo port install python26
install python_select
sudo port install python_select
select python 2.6 as system default
sudo python_select python26
install xapian-core
sudo port install xapian-core
install xapian-bindings WITH PYTHON VARIANT
sudo port install xapian-bindings +python26
copy all your python libs from "/Library/Python/2.5/site-packages" to
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages"
wich is your new default site-packages folder!
restart Terminal
Done!