I can't imort pyPDF2 module in python [duplicate] - python

This question already has answers here:
"no module named PyPDF2" error
(10 answers)
Closed 2 months ago.
I have installed pyPDF2 module using pip install pyPDF2 command in it is successfully installed. But when I import pyPDF2 module i get error no module named pyPDF2

Probably because your pip is not for your python. Check if
which pip
which python
show the same parent directory.
If they don't you should use another pip inside bin of which python. Or, the following
python -m pip install
may use the proper pip for your python.

Related

Why python didn't see nltk module? [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 4 months ago.
I cant run my programm because nltk module is missing but i just intstalled it and it just right here in the folder
I tried to reinstall my python, and tried to change python interpreter but nothing worked
How have you actually installed nltk?
You can check if it's actually installed with pip freeze.
What might be happening here is that you could have another version of python installed, so make sure that you actually call the same interpreter for checking and installing with pip, in your case E:/pythonProject1/Scripts/python.exe -m pip freeze and E:/pythonProject1/Scripts/python.exe -m pip install nltk

Module Not Found, but Requirement already satisfied [duplicate]

This question already has answers here:
ImportError: No module named 'pygame'
(25 answers)
How to import pygame in visual studio code?
(4 answers)
Closed 1 year ago.
In my code I have:
'''import pygame'''
When I run:
ModuleNotFoundError: No module named 'pygame'
When I pip install pygame (also tried pip3 install pygame and pip3.7 install pygame):
Requirement already satisfied: pygame in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.0.1)
Really lost here any help appreciated.
python --version = Python 3.7.4
pip --version =
pip 21.2.4 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
While getting such error even after installing the required module, check for the following:
The python environment/ installation used by your IDE should be same as the environment where the module is installed.
Else, change the environment to the Python environment
paste the path to python.exe inside bin folder of your environment
And install the package again.
Specific for VS Code
Click on python followed by version number or venvin the bottom ribbon of the editor and add the path to interpreter or choose an existing interpreter you want to use.

ModuleNotFoundError, but the package should be there [duplicate]

This question already has answers here:
ModuleNotFoundError: No module named 'requests' after pip install [duplicate]
(2 answers)
Closed 1 year ago.
Here is what I'm using:
Python 3.7.x on PyCharm 2018.2.4
Windows 10.
I'm following a tutorial about website parsing, but the struggle begins before I can even really start out.
I get the error message:
ModuleNotFoundError: No module named 'requests'
The package should be installed properly (pip3 install requests) and I run only that single version of python as far aI i know. I can find the package in the directory I'd expect it to be (C:\Users\Bob\AppData\Local\Programs\Python\Python37\Lib\site-packages).
I expect the same problem for the other package (beautifulsoup4), but the script doesn't even get that "far".
So, I'm aware that I must've done something incorrectly but I can't figure out what.
Any advice?
requests is a module which is needed for the script / the command you are trying to run but seems not to be part of the python installation or the python distribution you choose.
I can guess that you got the error while entering the following line:
>>> import requests
I would run the pip install request command from powershell and try to install the package:
python -m pip install requests
I do not know what you want to use python for but I usually advise to use a python distribution such as Anaconda which contains plenty of additional packages including requests.

Cannot find YAML module [duplicate]

This question already has answers here:
ImportError: No module named 'yaml'
(9 answers)
Closed 4 years ago.
I am currently trying to use my YAML file but I get an error when trying to run my programme when it reaches 'import yaml' line.
The error is shown below
ImportError: No module named yaml
Even though I was able to successfully install it
Collecting pyyaml
Installing collected packages: pyyaml
Successfully installed pyyaml-3.13
Any help would be great, thanks
which python
/home/user/anaconda3/bin/python
which pip
/home/user/anaconda3/bin/pip
These must match. Than you can run pip install PyYAML
For such problems I can recommend conda. Using conda all dependencies are matched.
Here is a description how to use environments with conda.
The good thing about this approach is that you can change the version of your software (e.g. python) at any time, not affecting your other projects.
Moreover you can use pip in it just as before.

How do you specify which python distribution to install a module for with pip? [duplicate]

This question already has answers here:
How to use pip with Python 3.x alongside Python 2.x
(11 answers)
Closed 6 years ago.
I am trying to install the yweather module for python 3.5 on my mac using pip install, however as i have both python 3.5 and 2.7 i don't know how to specify which distribution to install the module for - how would you do this?
pip will install a module for the default python on your system. If you want to be sure that pip installs for a specific version, use pip2 or pip3 instead of pip.
Also if you aren't already, you should consider using virtual environments.
As seen in the docs
Download the most recent release from yweather’s PyPi page. Unpack the
tarball. From inside the yweather-0.X directory
Python 2
python setup.py install
Python 3
python3 setup.py install

Categories

Resources