When I run my code that includes psutil module I encounter the following error:
Traceback (most recent call last):
File "/Users/alek/Desktop/coloring/solver.py", line 4, in <module>
from psutil import cpu_count
ModuleNotFoundError: No module named 'psutil'
Although, when trying to install the module in terminal, I can see the following
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: psutil in /opt/homebrew/lib/python3.9/site-packages (5.9.1)
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
WARNING: There was an error checking the latest version of pip.
How should I ensure that the module is in the right environment and can be used by my program?
Thanks in advance!
try to upgrade it
sudo pip install --upgrade psutil
try to run this command in python shell:
import site
site.getsitepackages()
actually, it is trying to search psutil module in one of the Xcode path.
see if you have psutil in this path:
/Applications/Xcode_13.4.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages
if not add the psutil module here and it should work.
it worked for me.
Basically, I recently started Python. I'm working on a project where I need audio to play. I searched up some libraries that can play audio and tried simpleaudio. I'm using Windows and sucessfull installed simpleaudio using: pip3 install simpleaudio.
However, when I tried to use simpleaudio in my project with import simpleaudio as sa, it gives me this error:
Traceback (most recent call last):
File "d:\coding\python\python projects\random tests\soundtest.py", line 1, in
import simpleaudio as sa
ModuleNotFoundError: No module named 'simpleaudio'
Any idea what is wrong?
After I installed simpleaudio, import simpleaudio as sa worked with no errors. I've run into similar errors before, and it was always because the version of pip I was using and the Python interpreter I was using didn't match. You probably need to either switch to using the same interpreter as pip3 or install the package for whatever interpreter you're using
The most probable issue is the use of differing version of python. For instance if you use pip3 it is for python3 only
Since the module was not found try
pip install simpleaudio
and then importing again
It's possible you installed the library for python2 instead of python3. In ubuntu pip is python2 and pip3 is python3- I'm not sure if that's the case on windows or not.
I am trying to import Crypto in my python program but i got error.
i am working on windows. please help.
cmd
C:\Users\Raw.306498\Desktop>pip3 install --upgrade pycryptodome
Requirement already up-to-date: pycryptodome in c:\users\raw.306498\appdata\lo
cal\programs\python\python37\lib\site-packages (3.8.0)
C:\Users\Raw.306498\Desktop>python test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
from Crypto.Cipher import DES
ModuleNotFoundError: No module named 'Crypto'
C:\Users\Raw.306498\Desktop>
test.py
from Crypto.Util.asn1 import DerBitString
from binascii import hexlify, unhexlify
passw=b'21566572697461733131'
s = unhexlify(passw)
cred=str(s,'ascii')
solution to this problem for windows users is explained in the documentations here
and it says:
The root cause is that, in the past, you most likely have installed an unrelated but similarly named package called crypto, which happens to operate under the namespace crypto
Fix the problem with:
pip uninstall crypto
pip uninstall pycryptodome
pip install pycryptodome
more elaboration of the cause can be seen in this github issue
UPDATE:
If the solution quoted from documentation did not work you have to change the package folder name from crypto into Crypto.
to find where the package folder is located:
find out where your python executable is located by this command: where python.
Output should look like this:
C:\Users\_YourUserName_\AppData\Local\Programs\Python\Python37-32\python.exe
Now change your directory in cmd to the folder containing python:
cd C:\Users\_YourUserName_\AppData\Local\Programs\Python\Python37-32\
run these:
cd ..
cd cd Lib\site-packages
open the explorer in this directory:
explorer .
In the opened explorer, you can see a folder named: crypto rename it to Crypto. (the second one starts with a capital C)
i solved this issue
actually a similar named file is already store in python library so first i delete it then install pycrypto using pip
Depending on which installation of Python I am using I have some problems to load a module. When I type
from quantecon import approx_markov
in the terminal using Python 3.4.0, the following error message is returned:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/quantecon/__init__.py", line 6,in <module>
from asset_pricing import AssetPrices
ImportError: No module named 'asset_pricing'
In the folder /usr/... as referred to above, I do however find a module called asset_pricing. (I have to admit that I additionally do not understand why the module asset_pricing interferes.)
I installed quantecon with:
pip3 install quantecon
I suspect that the problems are related to the Python version I am using. I also installed
pip install quantecon
and when I call the module approx_markov form the terminal, using Python 2.7.6 (I think this is the standard Python version of the OS I am using) I do not receive any error message. To solve the problem I already followed the instruction in the following discussion but to no avail Python3 has no acces to python2 modules (ubuntu).
The currently released version of quantecon is not Python 3 compatible; it uses relative imports and these are not supported anymore in Python 3.
The version in the source repository has been refactored and updated, and looks like it'll work with Python 3. You'll need to install that version instead:
pip3 install -U git+https://github.com/jstac/quant-econ.git
where -U tells pip3 to upgrade the package.
Note that there have been a lot of changes recently; use at your own risk. You could stick with Python 2 and wait for an official release.
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