简体   繁体   English

错误:没有名为“psutil”的模块

[英]Error : No module named 'psutil'

I've been trying to install Peter Chervenski's MultiNEAT and ran into a problem while running setup.py ( python setup.py build_ext ):我一直在尝试安装Peter Chervenski's MultiNEAT ,但在运行 setup.py ( python setup.py build_ext ) 时遇到了问题:

File "c:/Users/1234/Documents/Alex/multineat/peter-ch-MultiNEAT-f631e2f/setup.py", line 7, in from site-packages import psutil'文件“c:/Users/1234/Documents/Alex/multineat/peter-ch-MultiNEAT-f631e2f/setup.py”,第 7 行,在 from site-packages import psutil 中

And I made sure this module is installed: used pip install a couple of times and it said:我确保安装了这个模块:使用pip install了几次,它说:

Requirement already satisfied: psutil in c:\users\1234\appdata\local\programs\python\python36-32\lib\site-packages要求已经满足:psutil in c:\users\1234\appdata\local\programs\python\python36-32\lib\site-packages

And I checked this directory myself and found psutil module there (I even deleted it and reinstalled one more time).我自己检查了这个目录并在那里找到psutil模块(我什至删除了它并重新安装了一次)。 And after that, I still got the same error with Python not seeing psutil .在那之后,我仍然遇到与Python not seeing psutil相同的错误。 Is there any way I can solve this problem?有什么办法可以解决这个问题吗? (I am using Windows 10 , latest version of Python ) (我用的是Windows 10 ,最新版Python

Error I got in windows 10 while executing a python script ->我在执行 python 脚本时在 Windows 10 中遇到的错误 ->

Traceback (most recent call last):回溯(最近一次调用最后一次):

File "C:\\Users\\YOUR NAME\\Desktop\\Sample.py", line 2, in import psutil导入 psutil 中的文件“C:\\Users\\YOUR NAME\\Desktop\\Sample.py”,第 2 行

ImportError: No module named psutil导入错误:没有名为 psutil 的模块

This is how I resolved the issue ->这就是我解决问题的方法->

C:\python -m pip install --upgrade pip

[Latest pip version got installed successfully] 【最新pip版本安装成功】

C:\>python -m pip install psutil

Collecting psutil
  Downloading https://files.pythonhosted.org/packages/50/6a/34525bc4e6e153bf6e849a4c4e936742b365f6819c0462cebfa4f082a3c4/psutil-5.4.7-cp27-none-win_amd64.whl (220kB)
    100% |UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU| 225kB 696kB/s
Installing collected packages: psutil
Successfully installed psutil-5.4.7

Finally, Sample.py got executed successfully最后,Sample.py 执行成功

这对我有用..

sudo pip install --upgrade psutil

Follow these steps on windows:在 Windows 上执行以下步骤:

  1. Open command prompt in administrator mode管理员模式下打开命令提示符
  2. Enter Command python -m pip install psutil输入命令python -m pip install psutil
  3. Upgrade pip if outdated python -m pip install --upgrade pip如果过时,请升级 pip python -m pip install --upgrade pip

Process Example流程示例

I solved a problem and if you had a similar problem you should try this:我解决了一个问题,如果你有类似的问题,你应该试试这个:

  1. upgrade pip to the latest version ( python -m pip install --upgrade pip )pip升级到最新版本( python -m pip install --upgrade pip
  2. delete psutil ( C:\\Users\\(your username)\\AppData\\Local\\Programs\\Python\\Python36-32\\Lib\\site-packages ) if you have it installed already删除psutil ( C:\\Users\\(your username)\\AppData\\Local\\Programs\\Python\\Python36-32\\Lib\\site-packages ) 如果你已经安装了
  3. reupload psutil now using pip install psutil重新上传psutil现在使用pip install psutil

. . It helped me and if you have a permission error, try opening cmd as administrator.它帮助了我,如果您遇到权限错误,请尝试以管理员身份打开 cmd。

I had that problem trust me this works 100%.我有这个问题相信我这工作 100%。 I am using VS Code you just have to install it with pip normally but sometimes it doesn't add it to your working directories ( venv\\lib\\site-packages\\ ) folder your editor is using.我正在使用 VS Code,您只需要正常使用 pip 安装它,但有时它不会将它添加到您的编辑器正在使用的工作目录 ( venv\\lib\\site-packages\\ ) 文件夹中。 So just copy and paste it there from here C:\\Users\\(your username)\\AppData\\Roaming\\Python\\Python39\\site-packages所以只需从这里复制并粘贴它C:\\Users\\(your username)\\AppData\\Roaming\\Python\\Python39\\site-packages

I resolved this issue as below: It seems, every time i was trying to upgrade psutil using "pip install psutil" it just showing the requirement is satisfied and showing 5.7.2.我如下解决了这个问题:看来,每次我尝试使用“pip install psutil”升级 psutil 时,它只显示满足要求并显示 5.7.2。

  1. Go to the folder where Python is install and psutil is available eg "C:\\Python\\Lib\\site-packages"转到安装 Python 且 psutil 可用的文件夹,例如“C:\\Python\\Lib\\site-packages”
  2. find all psutil related filesand rename them to something else eg Old__psutil Old_psutil-5.7.2.dist-info找到所有与 psutil 相关的文件并将它们重命名为其他名称,例如 Old__psutil Old_psutil-5.7.2.dist-info
  3. Run "pip install psutil" from bash or command line从 bash 或命令行运行“pip install psutil”
  4. It updated for me to 5.8.0它为我更新到 5.8.0

This resolved my issue.这解决了我的问题。

This worked for me.这对我有用。 I had multiple version of python in my ubuntu system.我的 ubuntu 系统中有多个版本的 python。

$ sudo apt install python3.6-dev

Inconsistencies can happen if you have multiple versions of windows installed on your system.如果您的系统上安装了多个版本的 Windows,则可能会出现不一致的情况。 Check for the default python directory path and make sure 'psutils' is updated in that directory.检查默认的 python 目录路径,并确保该目录中的“psutils”已更新。

I got the same issue and solved it by specifying the exact (virtual environment / global) pip you are using .我遇到了同样的问题,并通过指定您正在使用的确切(虚拟环境/全局) pip解决它。 In my case (using a virtual environment), after executed pip by using the absolute path, I installed psutil successfully.在我的情况下(使用虚拟环境),使用绝对路径执行pip后,我成功安装了psutil

psutil 问题

These two commands typed in the SSH shell worked for me.在 SSH shell 中键入的这两个命令对我有用。 The apt install is what was showing me the error mentioned. apt install 向我显示了提到的错误。

sudo apt install pip
python3 -m pip install psutil

Result: python3 -m pip install psutil Collecting psutil Downloading psutil-5.9.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (284 kB) |████████████████████████████████| Result: python3 -m pip install psutil Collecting psutil Downloading psutil-5.9.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (284 kB) |███████████████ █████████████████| 284 kB 2.0 MB/s Installing collected packages: psutil Successfully installed psutil-5.9.1 284 kB 2.0 MB/s 安装收集的包:psutil 成功安装 psutil-5.9.1

Hope this helps someone...希望这可以帮助某人...

I was having same issue, but not quite exactly the same circumstances.我遇到了同样的问题,但情况并不完全相同。 I am writing this for any people that have the same problem as I did.我正在为所有遇到与我相同问题的人写这篇文章。

I was running sudo python script.py (sudo was needed since I wanted to alter cpu frequencies) but Error: No module named 'psutil' appeared.我正在运行sudo python script.py (因为我想改变 cpu 频率,所以需要 sudo)但是Error: No module named 'psutil' I checked my python version with我检查了我的 python 版本

python --version

and it was 3.8, but when I checked my version with它是 3.8,但是当我检查我的版本时

sudo python --version

it was running version 2.7.它正在运行 2.7 版。 Once I ran一旦我跑了

sudo python3 script.py

it ran smoothly.它运行顺利。 Of course I had already verified I had the newest pip installed + psutil library installed on python3.当然,我已经验证了我在 python3 上安装了最新的 pip + psutil 库。 Basically, make sure you are running the correct python version and you have all libraries/package managers up to date, hope this helped!基本上,确保您运行的是正确的 python 版本,并且所有库/包管理器都是最新的,希望这对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM