fabric python install problem - python

Just installed fabric, trying to use to same fabfile that works on a different server, getting this error here:
Traceback (most recent call last):
File "/var/lib/python-support/python2.6/fabric.py", line 1211, in main
load(fabfile, fail='warn')
File "/var/lib/python-support/python2.6/fabric.py", line 467, in load
execfile(filename)
File "fabfile.py", line 2, in <module>
from fabric.api import *
ImportError: No module named api

Your problem is that you named a file fabric.py somewhere in your python path. (probably in your current working directory)
Rename it to something else and then it will not have any issues.
I accidentally do this all the time and it is annoying.

Looks like you have different versions of Fabric on those servers, they changed the module structure recently.

I just got this message on my Ubuntu 9.10 machine; Ubuntu ships with an old version of fabric (0.1.1). The latest release version is 0.9.0.
sudo easy_install fabric
should get you the latest released version.

I had this problem when I installed fabric using disutils on OS X. So I removed it and reinstalled with pip. works fine.
To remove: Delete the Fabric egg in site-packages directory.
then install using pip
sudo pip install fabric

Related

how to install selinux package in a venv, from a self contained python installation

I have built python3.8.12 from source and installed it in /python3 on a machine with no other python anywhere. there are no "system" packages. (it is rocky8.5 linux)
Now I create and activate a venv from that python:
/python3/bin/python -m venv myvenv
source myvenv/bin/activate
Now I install packages in this venv from a local repository
pip install -r requirements.txt --index-url=file:///python3/pypkgs/simple
The repository was built with pip2pi. this is all being designed for full airgap deployments.
Now I cannot import selinux as it is apparently not aware of the selinux in the venv, and is instead searching the system.
(myvenv) [root#node1]# python -c "import selinux"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/myvenv/lib/python3.8/site-packages/selinux/__init__.py", line 104, in <module>
check_system_sitepackages()
File "/root/myvenv/lib/python3.8/site-packages/selinux/__init__.py", line 100, in check_system_sitepackages
raise Exception(
Exception: Failed to detect selinux python bindings at ['/python3/lib/python3.8/site-packages']
I use the selinux package as an example because it is the issue I am currently faced with. Not sure if this is a wider problem yet. Haven't tested exhaustively, but have not had issue with any other package.
Ok I guess I got it working. Not sure how horrendous of a fix this is.
First, I installed selinux to the system /python3 (apparently you can't use selinux within a venv - has to be system level?)
And then I hardcoded my /python3/bin/python to this line: https://github.com/pycontribs/selinux/blob/321d66619ed59bec00a9dc6216ce417d7befec41/selinux/__init__.py#L76

Installing PIP Python 3.6.3 Ubuntu 16.04 Zlib Not Available, But It's Installed

I'm trying to follow this tutorial on installing Python 3.6.3 and PIP with virtual environments, but when I get to sudo python3.6 get-pip.py I get the error
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
but I have zlib1g-dev installed and don't know how to fix this problem. I've googled a lot and tried reinstalling, but haven't had any success.
Sorry to start a new question, but I did not have enough Karma to comment on the other one. Any help would be greatly appreciated.
Update: I ended up installing everything from source instead of using any packages and it seems to be working. I was not able to solve the problem, but found an alternative way to get things working.
For pip to work, Python needs to be linked to the zlib library when Python itself is installed. It appears that either zlib was not installed when you installed Python, or at least that the Python installer couldn't locate it. To help it along, you may issue the following before installing Python. In bash syntax,
zlib_lib="/usr/lib32"
zlib_inc="/usr/include"
export CPPFLAGS="-I${zlib_inc} ${CPPFLAGS}"
export LD_LIBRARY_PATH="${zlib_lib}:${LD_LIBRARY_PATH}"
export LDFLAGS="-L${zlib_lib} -Wl,-rpath=${zlib_lib} ${LDFLAGS}"
Here I've assumed that zlib is installed under /usr/lib32 and /usr/include/. To check this, look for the libz.so.1 file in the "lib" directory and the zlib.h file in the "inc" directory. If you find them somewhere else, simply change zlib_lib and zlib_inc accordingly.
IF you have different versions of Python installed it is likely the install is on another version. for example. I have pyperclip in 3.6.3 32bit version, but I an not access it in 3.6.3 64bit or 3.7.2dev.

Python 3.5 pip version conflict with python 2.7

I am trying to install a software using pip install and my python and pip versions are 3.5. but when I run sudo pip install -e . I get the following error.
Traceback (most recent call last):
File "/usr/local/bin/pip3.5", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.14-py2.7.egg/pkg_resources.py", line 2675, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.14-py2.7.egg/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==8.1.0
Why Do I get an error with python 2.7 and please some one could sortout my issue.
Your pip version and python versions are separate. It looks like your package requires exactly pip 8.1.0. You have to either upgrade/downgrade to that version first, or modify the software to work with whichever pip you have available.
Also, it may be easier to install the software in a virtual environment rather than system/global one. Changing the system version of pip may break either current apps, or the future pip package updates.

Cannot run anything from mysql-utilities: "No module named mysql.utilities.common.tools"

RedHat 6.5. Installed via RPM repos the mysql-utilities 1.3.6 and mysql-connector 1.1.6 packages. mysqlrplcheck could be executed (though I never found out if it actually worked). Then I realized that version of the suite is missing what I really need, which is mysqlrplsync. So I downloaded and installed 1.5.4 directly from Oracle. Found out mysql-connector 1.1 was too old and thus upgraded to 2.1.2 of that suite.
Now if I run any of the suites programs, I get:
Traceback (most recent call last):
File "/usr/bin/mysqlrplcheck", line 24, in <module>
from mysql.utilities.common.tools import check_python_version
ImportError: No module named mysql.utilities.common.tools
I think there should be a mysql.py/mysql.pyc in the <pythonlibpath>/ directory, but there is none. So is this a silly packaging error on Oracle's part?
Note: Not a duplicate of 19247867 which wasn't really answered anyway. Different environment, (significantly) different versions of the software.
Not a duplicate of 24267017 nor its referral because the connector is definitely installed. (Though that might be the problem... see my comment)
UPDATE: Possibly fixed in mysql-utilities 2.1.3. See last comment at bug report: https://bugs.mysql.com/bug.php?id=77819
For anyone getting this error on Ubuntu, installing the .deb from oracle or using apt-get did not work for me, what did work was:
wget https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-utilities-1.5.6.tar.gz
tar -xvf mysql-utilities-1.5.6.tar.gz
cd mysql-utilities-1.5.6
sudo python2.7 setup.py install

installing paramiko on Windows

This may sound like a repeated question on SF, but I could not find a clear answer to it, yet.So.
I installed Paramiko 1.7 with "setup.py install" command and while running the demo.py program, I got this error:
Traceback (most recent call last):
File "C:\Documents and Settings\fixavier\Desktop\paramiko-1.7\demos\demo.py", line 33, in <module>
import paramiko
File "C:\Python26\lib\site-packages\paramiko\__init__.py", line 69, in <module>
from transport import randpool, SecurityOptions, Transport
File "C:\Python26\lib\site-packages\paramiko\transport.py", line 32, in <module>
from paramiko import util
File "C:\Python26\lib\site-packages\paramiko\util.py", line 31, in <module>
from paramiko.common import *
File "C:\Python26\lib\site-packages\paramiko\common.py", line 99, in <module>
from Crypto.Util.randpool import PersistentRandomPool, RandomPool
ImportError: No module named Crypto.Util.randpool
I'm getting this error even after installing PyCrypto 2.1.
On running test.py(which comes with the installation), I got the following error -
Traceback (most recent call last):
File "C:\Documents and Settings\fixavier\Desktop\pycrypto-2.0.1\pycrypto-2.0.1\test.py", line 18, in <module>
from Crypto.Util import test
File "C:\Documents and Settings\fixavier\Desktop\pycrypto-2.0.1\pycrypto-2.0.1\build/lib.win32-2.6\Crypto\Util\test.py", line 17, in <module>
import testdata
File "C:\Documents and Settings\fixavier\Desktop\pycrypto-2.0.1\pycrypto-2.0.1\test\testdata.py", line 450, in <module>
from Crypto.Cipher import AES
ImportError: cannot import name AES
I don't have the confidence to go ahead and install AES after all this, for all I know I may get another ImportError!
Please advice.Is it the way of installation thats problematic?
Looks like your pycrypto installation is broken or not installed.
Try to get a pycrypto for python2.6 installer here and try again after installing it.
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
I tried Vijay's method,but it doesn't work.
I use the method on 'http://kmdarshan.com/blog/?p=3208',it works:
Goto to http://twistedmatrix.com/trac/wiki/Downloads and download the pycrypto package .exe for windows/python2.5. This is needed for running paramiko.
Next, download the paramiko package from http://www.lag.net/paramiko/.
Unzip paramiko to a temporary folder, better if you unzip it to the folder where python is installed.
Go into the folder for paramiko.
Open command prompt and see to it that you have python set as the environment variable.
Run this command python setup.py install
You will get a series of lines of compilation. Just make sure you dont have any error in them. If you have any errors you will need to re compile them again.
Just be be sure everything is alright import paramiko in your program and see.
FYI: paramiko is used for ssh..and so on.
Download paramiko for windows. You get the zip file:
www.lag.net/paramiko/
To build it you need the dependency package pycrypto. Again keep in mind you will need a matching version of pycrypto for your Python. This is a built version of Windows so no install is required. http://www.voidspace.org.uk/python/modules.shtml#pycrypto
You could do an easy_install by downloading setuptools but I ran into some issues so I chose to download MinGW tool. This is again an installation and no build is required. http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/mingw-get-inst-20110316/
Once you have pycrypto and MinGW installed on your windows machine, just browse to the folder where you extracted the paramiko module from the zip file and issue this command:
python setup.py build --compiler=mingw32 bdist_wininst
TADA! You are all set to use ssh on your windows machine with Python.
I have installed paramiko onto 64bit Windows 7 successfully:
Install Python2.7
Download 64bit PyCrypto installation package from: http://www.dragffy.com/posts/ython-pycrypto-2-4-1-32-and-64-bit-windows-32x64-amdintel-installers
Download paramiko package from: http://www.lag.net/paramiko/
extract paramiko package
start a command line terminal from the extracted paramiko package, run
"python setup.py install"
I wanted to install Paramiko for Python 3.3.2 on Windows XP. I followed the instructions here
After I downloaded all programs on the list for my Python version, Paramiko starts without problems.
Install python-2.7.3.amd64.msi
Install pycrypto-2.6.win-amd64-py2.7.exe
Install setuptools-1.4.2.win-amd64-py2.7.exe
Install pip-1.4.1.win-amd64-py2.7.exe
Download and extract https://github.com/paramiko/paramiko/archive/master.zip
The actual problem does not seem to be a broken Crypto install but a slightly different one. After installing paramiko and crypto with easy_install on windows I do have crypto installed but not Crypto. I installed the package PyCrypt (which gave an error because I didn't have a C compiler before I installed visual studio express)
It appears that the Crypto package you downloaded doesn't have AES...
you should try doing the following:
import Crypto
import Crypto.Util
import Crypto.Cipher
if any of those fail then you still need to make sure pycrypto is installed (see the link from S.Mark here), otherwise Paramiko might not depend on having AES (even though there is a test for that)
It seems PyCrypto uses a c-compiler(which is inherently present on the Linux system - gcc).
Also, somewhere on the PyCrypto readme.txt file says, it needs to be 'build' first, before doing an 'install'
On Linux, I build it first and then ran 'install' command on it and was successfully installed.
I searched for a long time looking for a solution to this problem. I'm running Windows 7 64-bit and python 2.7. None of the above solutions worked for me.
this one did
Don't forget to include the C++ compiler when you download the Microsoft SDK, it wasn't checked by default.
I downloaded the pycrypto 2.5 source to do the compile and the paramiko 2.3, things work well.
Here is a very precise answer:
Step 1: Go to https://github.com/paramiko/paramiko
Step 2: Download the zip file, and extract it
Step 3: Move into the folder and run python setup.py install
You are done!
I had the similar problem on my mac and the way I solved it was by simply just renaming the "crypto" directory to the "Crypto". I already had the paramiko and ssh installed in it. They both work perfectly fine now. However, this may or may not work for some one but this is just a simple thought on getting the ways around this problem.
just try
pip install paramiko
if this shows error, then
pip install cryptography
pip install paramiko

Categories

Resources