1

I'm not sure how to best address or query for this problem. I have a simple program that is using the fs.sshfs module which depends on paramiko and there fore cryptogaphy.utils. From my virtualenv with python version 3.5.2.

(venv) $ cat tump.py
from fs.sshfs import SSHFS

remote = SSHFS('rushmore')
print(*remote.listdir('.'), sep='\n')

My environment has the following modules installed.

(venv) $ pip freeze
appdirs==1.4.3
asn1crypto==0.24.0
bcrypt==3.1.4
cffi==1.11.5
cryptography==2.2.2
fs==2.0.21
fs.sshfs==0.8.0
idna==2.6
paramiko==2.4.1
pkg-resources==0.0.0
pyasn1==0.4.2
pycparser==2.18
PyNaCl==1.2.1
pytz==2018.4
six==1.11.0
typing==3.6.4

When I invoke python directly on the file, I recieve an AttributeError against getargspec.

(venv) $ python tump.py
Traceback (most recent call last):
  File "tump.py", line 1, in <module>
    from fs.sshfs import SSHFS
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/fs/sshfs/__init__.py", line 7, in <module>
    from .sshfs import SSHFS
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/fs/sshfs/sshfs.py", line 13, in <module>
    import paramiko
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/paramiko/__init__.py", line 22, in <module>
    from paramiko.transport import SecurityOptions, Transport
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/paramiko/transport.py", line 34, in <module>
    from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 7, in <module>
    from cryptography.hazmat.primitives.ciphers.base import (
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 11, in <module>
    from cryptography import utils
  File "/mnt/max/home/robinsph/git/HCPVaTT/venv/lib/python3.5/site-packages/cryptography/utils.py", line 85, in <module>
    signature = inspect.getargspec
AttributeError: module 'inspect' has no attribute 'getargspec'

When I invoke using a redirect to file descriptor,

(venv) $ python <(cat tump.py)
lib32
boot
var
app
bin
lost+found
usr
snap
vmlinuz
initrd.img
root
srv
proc
home
lib
lib64
sys
initrd.img.old
mnt
tmp
media
libx32
run
opt
.bash_history
sbin
vmlinuz.old
dev
etc

Can anyone reproduce this? I think I'm loosing my mind.

probinso
  • 309
  • 2
  • 9

1 Answers1

1

You have a different file called inspect.py on your path, and that's the one being imported. Add

import inspect
print(inspect.__file__)

to the start of your program to help find this. By itself, this is a duplicate of lots of questions. What's interesting about yours is that the redirect is changing the path. If we add print(sys.path[:3]) to an import of fs.sshfs after creating a local inspect.py, I get:

(36) dsm@winter:~/coding$ python <(cat tump.py)
/home/dsm/sys/miniconda3/envs/36/lib/python3.6/inspect.py
['/dev/fd', '/home/dsm/sys/miniconda3/envs/36/lib/python36.zip', '/home/dsm/sys/miniconda3/envs/36/lib/python3.6']
(36) dsm@winter:~/coding$ python tump.py 
/home/dsm/coding/inspect.py
['/home/dsm/coding', '/home/dsm/sys/miniconda3/envs/36/lib/python36.zip', '/home/dsm/sys/miniconda3/envs/36/lib/python3.6']
Traceback (most recent call last):
  File "tump.py", line 6, in <module>
    from fs.sshfs import SSHFS
[...]
AttributeError: module 'inspect' has no attribute 'getmro'

and the reason the file descriptor version works is because the effective "local" path is now /dev/fd and not /home/dsm/coding, and /dev/fd doesn't contain the inspect.py collision. There will be minor differences (I'm using 3.6, etc.) but probably this is the same cause.

DSM
  • 342,061
  • 65
  • 592
  • 494