Fabric and Paramiko - python

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

Related

Keyring apparently not installed correctly with pip macos

I want to use the Python package keyring to avoid exposing passwords in my Python scripts. According to what I've read, all you need to do is pip install keyring and then start storing and retrieving credentials. I've done this on both my Mac laptop (Big Sur) and a CentOS 7 box. On my Mac, pip list shows that version 23.1.0 of keyring is installed, and the command line utility is available. However, when I try to set a password using the command line or in python using keyring.set_password(...) I get the following error:
File "/lib/python3.7/site-packages/keyring/backends/macOS/init.py", line 38, in set_password
api.set_generic_password(self.keychain, service, username, password)
NameError: name 'api' is not defined
Line 12 of the init.py is a simple import of the api module:
from . import api
and then line 38, where the error is reported, tries to set the password:
api.set_generic_password(self.keychain, service, username, password)
Why am I getting this error? I read somewhere that you shouldn't install keyring in a venv with pip but I'm not certain why not. Any help is appreciated.
Error was introduced with version keyring==23.1.0 (Aug 15, 2021)
Once I downgraded to keyring==23.0.1 (March 25, 2021), the problem went away.
Try installing the six package by typing this in the command prompt/terminal:
pip install six
Somehow, the keyring package isn't installed properly on MacOS. See here.
Run this command:
$ /usr/local/lib/python3.7 -c "import keyring.backends._OS_X_API"
That should produce the underlying exception that's causing the module to be missing.
EDIT:
Try adding this
if sys.platform == 'darwin': # It's a solution for Mac
import keyring.backends.OS_X
keyring.set_keyring(keyring.backends.OS_X.Keyring())
else: # It's a solution for Windows
import keyring.backends.Windows
keyring.set_keyring(keyring.backends.Windows.WinVaultKeyring())

Errors by installing Python modules Pygame and Pygame Zero

I've succesfully installed Python version 3.8.1 and also PIP.
After that i want to install Pygame and Pygame Zero with the commands
pip install pygame
or
pip install pgzero
But I get the following error:
C:\>pip install pygame
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python38\Scripts\pip.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable
Also with the --user command it doesn't succeed:
pip install pygame --user
or
pip install pgzero --user
What am I doing wrong here now?
I also got that problem long ago.
You can try this:
pip uninstall pygame
pip uninstall pgzrun
then download it by:
pip install pygame
pip install pgzrun
Info of your assets are little low.. But if you have Python 2 and 3, try manage your alias on CMD by checking your current python variables from /usr/bin and from CMD type "python --version" to see current default. If it says Python2.7 you can chance that with "alias" command below (reason to do that, is 2.7 support is ending 1.1.2020 and old pip for it too. So in future, you should upload new modules just for Python3.7). If you have 2.7 in your PC and you have been using it for some time, you should not try to remove it.
So just in case:
$ alias python="/usr/bin/python3.7"
Then use command
$ sudo pip3 install pygame
This should work. If not, there is some setting problems on your module site.
Give a hit with this and if it doesn't work, let us know. I can give instruction to get it to work. It requires few steps at (in my case:)
/home/usr/Python-3.7.4/Modules/Settings.
It can (I'm not sure with these modules but..) require to set SSL connection too, but it can be done from there too, without any coding.
Thank you for the quick arswers!
It is succeeded by giving the commands:
py -3 -m pip install pygame --user
py -3 -m pip install pgzero --user
The only warnings i got by installing pgzero were:
Collecting pgzero
Downloading .....
Installing collected packages: numpy, pgzero
WARNING: The script f2py.exe is installed in 'C:\Users\Han\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script pgzrun.exe is installed in 'C:\Users\Han\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.18.0 pgzero-1.2
Oh.. I didn't know, you are using Windows.. My last answer dried down with that. It was for Linux.
Either way, when you installed python, did you mark the PATH in installation process?
It shows when installation windows pops up.
I'm little noob with windows, but I expect it to be as same as in any operation systems.
If you didn't, its easier to remove Python and install it again, than try to mark the PATH after installing. After all its just 1/2 min job.

Failure: Centos 6.4 python easy_install is broken

I've looked at quite a lot of related questions here - no help for me. I need to repair easy_install, so that I can update distribute to a version >=0.6.28, so that I can update python matplotlib using pip and not yum.
In the process of trying to update python matplotlib from 0.99 (the default with Centos64) to 1.4.x, I got into this trouble:
pip install --upgrade matplotlib tells me this:
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.10 (/usr/lib/python2.6/site-packages))
So I followed the suggestion and saw that some 0.7.x version of distribute was installed (so it seemed). Re-ran the pip command and got the exact same complaint.
Trouble with easy_install?
It was either now, or maybe after performing yum remove, then install python-setuptools that I discovered easy_install is thoroughly broken. Now when I try to run easy_install, I get this stacktrace:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 9, in <module>
load_entry_point('distribute', 'console_scripts', 'easy_install')()
File "/usr/local/lib/python3.3/site-packages/setuptools-18.2-py3.3.egg/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.3/site-packages/setuptools-18.2-py3.3.egg/pkg_resources/__init__.py", line 2681, in load_entry_point
raise ImportError("Entry point %r not found" % ((group, name),))
ImportError: Entry point ('console_scripts', 'easy_install') not found
Look at that - why is it referring to python3.3? I don't think I've got that installed. My default python is 2.6.6.
Any ideas? TIA.
Fixed it. The python3.3 bit was my clue. I found the python script for easy_install, in /usr/local/bin. The very first line designated /usr/bin/python3.3 to execute the script. Changed to 2.6 and then was good to go.
In the end I was not able to upgrade matplotlib from 0.99 to 1.4.3, because I could not upgrade basemap from 0.99 and some conflicts arose. Rather than punish myself with trying to build from source, I think I should simply upgrade my entire VM to Centos7 and I will then have much newer matplotlib.

Easy_install and Pip doesn't work

Easy_install and Pip doesn't work anymore on python 2.7, when I try to do:
sudo easy_install pip
I get:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.15
And when I try:
sudo pip install [package]
I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.2
I've already install both of them (and yes, first deleted them), but no result...
Thanks!
(I tried already this post)
I had this issue where python's distribute package wasn't installed for some reason. After following the instructions on python-distribute, i got it working.
install the distribute package as follows:
$ wget https://web.archive.org/web/20100225231201/http://python-distribute.org/distribute_setup.py
$ python distribute_setup.py
EDIT: http://python-distribute.org/distribute_setup.py no longer works:
hopefully this will resolve your problem with running
$ sudo easy_install
Happy Coding!
If you installed a new version of easy_install through Distribute, the new command may have been installed in another directory, most likely /usr/local/bin/. But the traceback shows you were using /usr/bin/easy_install. Try this:
sudo /usr/local/bin/easy_install ...
Try
sudo easy_install Distribute
and if that exists, but is too old
sudo easy_install -U Distribute
Looks like either Distribute/setuptools (it's old name) is messed up or Python package settings. If either of these do not help, try removing the full Python 2.7 installation and reinstall everything from the scratch.
Possible reasons for the mess is that you have used both sudo easy_install / sudo pip and Linux distribution packages to mix and match system-wide installation packages. You should use virtualenv instead if you use pip/easy_install (no sudo needed)
http://pypi.python.org/pypi/virtualenv
I had a similar problem, but things were working fine as root. In my case, I found that the permissions on the python packages were not readable by the ID I was running the command under.
To correct it, I ran the following command to open the permission for read and execute to all users:
sudo chmod o+rx -R /usr/local/lib/python2.7/dist-packages/*.egg
I had similar issue when trying to install package via pip with python 3.6 on windows. (pip is supposed to work out of the box with this install)
The problem was not running as administrator.
Running cmd as administrator and then installing my package worked:
python -m pip install pylint
I was trying to get pip to work on the 2.7.0 version, but it seems like it doesn't come with the easy_install/pip files (Script folder in main directory), installing 2.7.13 solved the problem for me.

I've installed xapian via macports, so why does this python app tell me that xapian needs to be installed?

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!

Categories