问题:无法在Pycharm3.5中导入模块
例如:选择 paramiko 包
软件包已安装
C:\Users\rj>pip3 install paramiko
Requirement already satisfied: paramiko in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (2.4.2)
Requirement already satisfied: pyasn1>=0.1.7 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from paramiko) (0.4.5)
Requirement already satisfied: bcrypt>=3.1.3 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from paramiko) (3.1.6)
Requirement already satisfied: pynacl>=1.0.1 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from paramiko) (1.3.0)
Requirement already satisfied: cryptography>=1.5 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from paramiko) (2.6.1)
Requirement already satisfied: cffi>=1.1 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from bcrypt>=3.1.3->paramiko) (1.12.2)
Requirement already satisfied: six>=1.4.1 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from bcrypt>=3.1.3->paramiko) (1.12.0)
Requirement already satisfied: asn1crypto>=0.21.0 in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from cryptography>=1.5->paramiko) (0.24.0)
Requirement already satisfied: pycparser in c:\users\rj\appdata\local\programs\python\python37-32\lib\site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko) (2.19)
Python脚本:
from paramiko import *
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(AutoAddPolicy())
ssh.connect("10.10.220.28", username="root", password="mavenir", port=22)
stdin, stdout, stderr = ssh.exec_command("ls")
ssh_output = stdout.read()
print(ssh_output)
观察到以下错误
C:\Users\rj\PycharmProjects\untitled1\venv\Scripts\python.exe C:/Users/rj/PycharmProjects/untitled1/ssh.py
Traceback (most recent call last):
File "C:/Users/rj/PycharmProjects/untitled1/ssh.py", line 1, in <module>
from paramiko import *
ModuleNotFoundError: No module named 'paramiko'
Process finished with exit code 1
还添加了环境变量。
在大多数软件包中都发现了这个问题
答案 0 :(得分:1)
在Pycharm中,转到File-->Settings--Project-->Project Interpreter
。然后点击加号,然后输入paramiko
。
从Pycharm中安装软件包有助于确保始终将其安装在venv中。
如果这不是解决方案,它应该将调查向前推进,并将回答@Cani
的问题。