installing paramiko on Windows - python

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

Related

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.

ImportError in Python

I tried to execute a program using geonames_rdf, but I cant execute it by this error:
Traceback (most recent call last):
File "geo1.py", line 13, in <module>
import geonames.config.log
ImportError: No module named config.log
I read several posts abot ImportError and I check the path of the system and it is correct. I'm working in a VirtualBox with a fresh Ubuntu 16.04.
The imports of my program are:
import sys
import os
import os.path
import logging
import geonames.config.log
import geonames.compat
import geonames.adapters.search
I've also tried add this line:
sys.path.append('/usr/local/lib/python2.7/dist-packages/geonames/')
The command that I used to instal this package was
sudo pip install geonames_rdf
Try appending site-packages not dist-packages. A bit of searching it looks like dist-packages is debian specific.
sys.path.append('/usr/local/lib/python2.7/site-packages/geonames/')
Reason:
Since you're installing 3rd party python package via pip it will not go into dist-packages and python rightfully cannot find it on the path.
Reference link:
What's the difference between dist-packages and site-packages?
I just tried to use geonames_rdf, but I didn't know I needed it to do a geonames search so I installed geonames first, then discovered I had to install fiona and gdal (I'm on Windows, had to install these two using prebuilt whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/). Don't know why these dependencies aren't baked into geonames.
Anyway once I then installed geonames_rdf it seemed to install into the geonames folder in c:\Python27\lib\site-packages, added at least the adapters package. In c:\Python27\lib\site-packages\geonames there is a config folder with log.py in it.

Python 3 installing tweepy

I have looked at all the forums, but nothing has worked so far. I have spent hours trying to install it so any help would be appreciated.
i have downloaded and unzipped tweepy, went on to the command prompt, typed "cd tweepy-master". This works, but when i type "python setup.py install" or "python setup.py build".
When i type "python setup.py install" the error says.
Traceback (most recent call last):
File "setup.py", line 4, in <module>
from setuptools import setup, find_packages
File "C:\Users\Sam Terrett\Documents\Portable Python 3.2.5.1\App\lib\site-packages\setuptools\__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "C:\Users\Sam Terrett\Documents\Portable Python 3.2.5.1\App\lib\site-packages\setuptools\extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Users\Sam Terrett\Documents\Portable Python 3.2.5.1\App\lib\site-packages\setuptools\dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
When i type "python setup.py build"
Traceback (most recent call last):
File "setup.py", line 4, in <module>
from setuptools import setup, find_packages
File "C:\Users\Sam Terrett\Documents\Portable Python 3.2.5.1\App\lib\site-packages\setuptools\__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "C:\Users\Sam Terrett\Documents\Portable Python 3.2.5.1\App\lib\site-packages\setuptools\extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Users\Sam Terrett\Documents\Portable Python 3.2.5.1\App\lib\site-packages\setuptools\dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
I saw alot of people saying to use pip, but i am struggling to install that to.
Thanks for the help
pip is the good way to install a package. If you are not interested then you can install from source.
But you have to remember that, If you are using virtualenv or virtualenvwrapper then you can use python setup.py install otherwise you should use sudo python setup.py install.
If you are windows user then, open your cmd with administator privilege and type python setup.py install.
Have you installed Python using the Windows installer from python.org?
Cause this comes with pip already bundled into it. (I can not check the exact location atm, as I am on a Mac, but according to this SO post it should be located under C:\PythonX.X\Scripts, if you kept the default install location - otherwise it should be located in <path-to-python>\Scripts of course).
Otherwise pip can easily installed using this script. Simply call python get-pip.py in the script location and pip should be available afterwards (if not directly from commandline with pip, than at least by using python -m pip.)
Having pip finally available, you should be able to easily install tweepy calling pip install tweepy (or python -m pip install tweepy respectively).
For further information on pip and the other options to install it, check https://pip.pypa.io/en/stable/installing/.
PS. If installing the package via pip does not work, this may be a compatibility issue. According to the tweepy github-page python 3.2 is not amongst the supported python versions. So if your portable python really has an interpreter versioned 3.2.... (you can check the version of your interpreter running python from cmd, which should print something like > Python 3.X.X), the package may not run properly at all (even if you can install it without a problem).
As the portable python apparently is no longer supported anyways, it may be worth trying a different solution. There are plenty suggested on the portable python website (I just know about Anaconda, but this works flawlessly). But if you only want to use python with tweepy and don't need anything like scipy or numpy, I'd suggest simply downloading the installer from the official website. As said, pip gets shipped with the standard installation and can be used to easily install most of the packages you will need. (Except for e.g. the abovementioned scipy/numpy, which require additional non-python libraries whose "manual" installation may not be worth the trouble and hence legitimates the use of a more comprehensive environment like Anaconda).

ImportError: No module named 'Crypto'

I am working with pycrypto. It works fine on my local windows machine, but when I move it to my python box I get an error with importing the module:
from Crypto.Cipher import ARC4
ImportError: No module named 'Crypto'
The output of python3.3 -c "from Crypto.Cipher import ARC4"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'Crypto'
output of pip3 list has a reference includes pycrypto (2.6.1)
I know it works with Python 2.7.6, but I wrote the script in 3.3 so it depends on some things from 3.3
As I already wrote in this answer:
WARNING: Don't use pycrypto anymore!
Use pycryptodome instead, via pip3 install pycryptodome.
But make sure that you don't have pycrypto installed, because both packages install under the same folder Crypto.
I am assuming that your "python box" is a remote computer.
First, make sure pycrypto is up to date (pip3 install --upgrade pycrypto). The older versions may not be compatible with python 3.3
If that doesn't work, try looking in site-packages (the directory) to make sure the functions actually exist.
If none of that works, it might be easier (just a suggestion) to use from future import the things you need. That way it is python 2&3 compatible.
Use pycryptodome, either install using pip or in case using IDE like pycharm install as a package via Preferences.
In case still gives error, use pycryptodomex (different from pycryptodome).
You will not see any error in importing from Cryptodome.Cipher import AES

fabric python install problem

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

Categories

Resources