ModuleNotFoundError: No module named 'cryptography' - Unable to recognize cryptography - python

I've installed and reinstalled Python 3 (using version 3.7.9) as well as pip and cryptography via the command prompt with success (message below):
Requirement already satisfied: cryptography in c:\users\myusername\appdata\local\programs\python\python39\lib\site-packages (3.4.7)
However, python is unable to recognize Cryptography and continues to give the same error message (below) each time I try and run a python script that is using cryptography to download packages.
from cryptography.hazmat.backends import default_backend
ModuleNotFoundError: No module named 'cryptography'
For whatever reason, python is unable to recognize that Cryptography is installed, or at least seems to be installed.
Is there any other way I can test or look for errors?
Does it take a certain amount of time after being installed before python can recognize cyptographgy (I've only just installed it an hour ago)?
I'll keep trying and re-attempting to find a solution, but if you've seen this before or know a solutions, please let me know.
The program I'm using is IDLE to run the scripts.
Thank you all in advance.

Related

Unable to find module install name / install module in Python

Appologies if this is confusing... I have spent most of today just trying to get the module for "shutil" installed in my instance of Python. I have tried what I thought would be the correct module from pypi.org to no avail. I have upgraded from 3.10 to 3.11 with no change in the message I have received. I am sure the pip install process works as I am able to install other modules fine. Despite my attempts, I continue to receive this message:
pip install shutil
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement shutil (from versions: none)
ERROR: No matching distribution found for shutil
Yes, I have seen a number of other solutions but so far they do not seem to work for me. Somewhere I even read that it was now an included module. That prompted me to upgrade my Python instance. I have also attempted including --trusted-host in my pip install attempts. Perhaps there is some Python config I missed? The environment paths are updated for the Python 3.11 install.
--corrected typo
shutil is a built in module, not one you have to install. Simply call
import shutil
at the top of your python code

failed to use urllib.request with python in vscode

I tried to import urllib.request wth python in vscode but kept getting the message: ImportError: No module named request. I have no problem importing just urllib, which I know is the right line for python2. I'm sure I'm using python3 as that's what I've selected in the interpreter path.
Here's the screenshot:
I've also put pip3 install urllib3 in the terminal and got this message which means python3 should have it:
Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.26.9)
any idea what have gone wrong or it's not the problem with python version?
This is related to your multiple environments. You should specify the installation path when using pip installation package.
pip install -t flodername urllib3 #the package of the python interpreter you chosen

ModuleNotFoundError using pip

I have installed the module alpha_vantage using pip. In CMD writing import alpha_vantage does not show an error message, so I assume it is installed properly.
However, when trying to import alpha_vantage in a python program I get this error: "ModuleNotFoundError: No module named 'requests'". I assume the issue is due to the location of the module.
The project is located here:
C:\Users\M\Documents\Python\Investering.
I tried placing the module here by pip: C:\Users\M\Documents\Python\Investering\modules\alpha_vantage
Note pip did not install the module there I simply copied the module folder and placed them in the project folder.
Is it possible to simply copy and paste module folders in other projects? Or how am I supposed to make python acknowledge the module?
The module was installed here:
C:\Users\M\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\alpha_vantage
I'm quite new to python. I have tried adding to sys.path the folder where the module was installed, but it did not seem to help.
Thanks for any help.
Edit: I tried pip install requests and it produced this:
Requirement already satisfied: requests in c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages
Someone mentioned running: "pip install foo"
It, however, produces this error message:
ERROR: Could not find a version that satisfies the requirement foo (from versions: none) ERROR: No matching distribution found for foo
I am using PyCharm.
I found my error. I had installed python from the website, but had unknowningly installed the 32 bit version, and a 64 bit version. I uninstalled all my python versions and pycharm. Then I reinstalled everything. Now I could easily make the module work. Thanks for the pointers.

How to fix "No module named 'nredarwin'" ImportError in python

I'm trying to access the Darwin feed from National Rail Enquiries in Python 3.5.3 on my Raspberry Pi. I'm trying to use a module called nre-darwin-py but after I've installed it using pip install nre-darwin-py (with and without sudo) I'm getting an ImportError when I try to import it in my program when using Python 3 (IDLE).
However, when I run python inside the command prompt I am able to import the module and try to use it, it works! I am also able to run some of the provided example code in the command prompt but not inside Python 3.
The code I'm using to import it is:
from nredarwin.webservice import DarwinLdbSession
but that's copied straight from the example code provided.
The code is running in a file called nre testing.py in /home/pi/Station Departures. From questions I've previously found here, the module has been installed in /usr/local/lib/python2.7/dist-packages/ which I think is what's causing the problem as I'm running Python 3.5.3.
I've tried installing the module using python -m pip install nre-darwin-py with and without sudo but the command prompt returns
Requirement already satisfied: nre-darwin-py in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: suds-jurko in /usr/local/lib/python2.7/dist-packages (from nre-darwin-py)
So the pi thinks that the module has been installed successfully (suds-jerko is a required module it installs)
I'm afraid I have so far been unable to find a solution so any help is most welcome.

Installing python package

I've already installed mechanize using pip install mechanize, such that when I enter it in the command prompt, the response is: Requirement already satisfied: mechanize in c:\users\wwl\anaconda3\lib\site-packages.
However, when I type import mechanize in the jupyter notebook, it gives an error:
ImportError: No module named '_mechanize'.
Where have I gone wrong?
Are you using Virtualenv?
If so, make sure you are importing the global libraries to your virtualenv (https://virtualenv.pypa.io/en/stable/userguide/#removing-an-environment).
If not, probably your Python version is not compatible. https://stackoverflow.com/a/24001585/2051397
Hope it helps

Categories

Resources