ModuleNotFoundError using pip - python

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.

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

Python package in the wrong path leading to ModuleNotFoundError [duplicate]

This question already has answers here:
pdfminer - ImportError: No module named pdfminer.pdfdocument
(4 answers)
Closed 4 months ago.
I have found a few solutions here and elsewhere, but none of them has worked. Context: I am trying to get pdf2txt going on my Pop!_OS 22.04 LTS system. I am using Python 3.10.6, with no other versions present. The command-line states that it requires python3-pdfminer to work, which I installed with apt. Output states that there is no module named 'pdfminer.high_level'. This comment here notes that it's a part of pdfminer.six which can be installed using pip, using a dash instead of a dot if it's inside a virtual environment.
$ python3 -m pip install pdfminer.six
states that requirements are already satisfied. To be sure, I also switched to a virtualenv and installed it there:
$ pip install pdfminer-six
Running pdf2txt in both cases results in the same error, i.e.
File "/usr/bin/pdf2txt", line 9, in <module>
import pdfminer.high_level
ModuleNotFoundError: No module named 'pdfminer.high_level'
I then tried to uninstall and reinstall pdfminer.six, first on the system wide version. python3 -m pip uninstall pdfminer.six (or just pip3) was not allowed, so I made a judgment of error and used sudo. Reinstalling now shows:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pdfminer.six in /usr/lib/python3/dist-packages (-VERSION-)
so I am not sure if it is properly installed. So I tried in the virtualenv where there were no problems. But the same error remains.
I reinstalled python3-pdfminer but without success.
In the virtualenv, I found:
./lib/python3.10/site-packages/pdfminer/high_level.py
./lib/python3.10/site-packages/pdfminer/__pycache__/high_level.cpython-310.pyc
I then created a test Python file that imports pdfminer.high_level and ran it, with no problem. I then did the same outside the virtualenv. pdfminer is imported correctly, but it can't import pdfminer.high_level. So I found the following:
When I uninstall pdfminer.six, it looks in /usr/local/lib/python3.10/dist-packages and removes it from there.
When I install pdfminer.six, it looks in /usr/lib/python3/dist-packages. Here, the high_level package is present. But the system always looks in /usr/local/lib/python3.10/dist-packages, so the package is never found.
So, I think that I found the cause of the problem. Running pdf2txt doesn't work in the virtualenv because it's still a file in /usr/bin that will look for a system-wide version. I suppose that I can update a system environment path to point to /usr/lib/python3/dist-packages, and solve it like this (pdf2txt is actually not binary so I can append to sys.path). But why has this discrepancy occurred in the first place? And what is the proper way to deal with it? After all, there is a reason why some packages are installed in different locations.
Many thanks.
EDIT: Adding to sys.path doesn't work, but adding to PYTHONPATH does. Not sure if this is something that I should watch out for in the future, or just a result of a Python executable installed in /usr/bin messing up with the idea of using a virtualenv in the first place.
Sometimes this issue happens when you have same name file in your working dir. So please check that first like if you have a file name "pdfminer.py".
If that is not the case then I usually try the previous version of lib.
you can try installing previous version with
pip install pdfminer.six==20220506

What is the reason of ModuleNotFoundError: No module named 'mysql' in Python 3.8.10 and Requirement already satisfied in anaconda location problem?

I need to import mysql-connector and I installed it by using pip install mysql-connector-python.
After the installation, I can see the same error is displayed.
After that again I tried to install mysql connector, but it displayed that Requirement already satisfied and show a path in anaconda lib folder.
Is there any effect from previous installation on Anaconda and how to import mysql-connector to code?
As a solution for that, I changed the interpreter of the code into ('base': conda). It worked correctly without any error.

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.

ModuleNotFoundError: No module named 'win32crypt'

I'm trying to run a Python module for a school project and I am getting this error ModuleNotFoundError: No module named 'win32crypt' at line import win32crypt.
I've search the website for solution and encountered a post that states pywin32 is required. So I installed it with pip. I also tried installing pypiwin32. None of these installs worked. Now I've tried Dependency Walker to see if there are any dependencies missing and I see at least 100 DLLs that are. How can I fix the issue?
win32cryrpt is a part of the Windows Extensions for Python or pywin32. It is a wrapper around the Windows crypto API. It doesn't make sense to try and install it without pywin32 and if your install of that has failed then that is the problem you have to solve.
Please try pip install pypiwin32 again, being sure to execute it in the correct folder, which is the Scripts subfolder of the Python environment you want to install it in. You may have more than one Python installation without realizing it, and if you run pip from outside that folder, you may get a different instance of pip. The standard location for Python installations is C:\Program Files\Python3x. If the pip install doesn't complete as expected then edit your question to include the messages from the failed install. Did not work isn't enough to go on.

Categories

Resources