I'm using Windows 10, Python 3.6.4. I'm trying to use the module Pyperclip and have installed it with pip:
c:\Users\Bertie>pip install pyperclip
Requirement already satisfired: pyperclip in c:\python36\lib\site-packages (1.8.0)
But when I try to run a program which uses this module, I get this error:
c:\Users\Bertie\scraping.py test
Traceback (most recent call last):
File "C:\Users\Bertie\scraping.py", line 3, in <module>
import webbrowser, sys, pyperclip
ModuleNotFoundError: No module named 'pyperclip'
How can I fix this? Thank you.
The reinstall trace shows you install the packge successflly for python36.
Check if there is more than one python in your system. Type "python" in your windows cmd console, and check the python version to see if python36 is the default one. Then explicitly use the python interpreter to start the script "python your_python_script.py".
Where is the py file? Maybe try cd-ing into the folder and run python (python3) scraping.py?
Also check that you have installed the correct interpreter and are using the correct version of python.
Maybe You Installed pyperclip in conda env or a virtualenv and you forgot to activate it ?
Because This Has Happened To Me Many Times.
Or Maybe You Have 2 Instances Of Python installed on your computer and you accidentally installed pyperclip in the other instance of python ?
Related
When I try to run a program that has import keyboard it gives me this error even though I installed it:
Traceback (most recent call last):
File "C:\Users\Diana\Desktop\test file.py", line 1, in
import keyboard
ModuleNotFoundError: No module named 'keyboard'
Does anyone know why?
It looks like you simply don't have the module named keyboard installed for the version of python that you're running the script with. Try running python -m pip install keyboard in a terminal outside of python to install the module, and try running the script again.
Assuming this is the module that's being referenced
You might have both Python 2 and Python 3 installed on your OS, which you can easily check by running this from your terminal:
pip --version
If the output ends with Python 2.X then you probably have two concurrent versions.
This implies that pip install keyboard would have installed the package for the respective Python version (2), i.e. you must explicitly point to pip3 implementation to get the package in the expected location:
pip3 install keyboard
Pls check if you installed the module 'keyboard', If done, make sure you call the function.
I want to use 'pynput', so I used pip to add it to my environment.
The installation proceeds without problem.
But I am unable to import it into my project.
I am using python 3.8.1 on my environment.
I used pip3 for installation.
I have already tried to install pynput, uninstall it and reinstall it multiple times.
My .py file doesn't have a confusing name like "pynput.py"
I am comfortable with my environment when I try to execute my file.
I am trying to run from my terminal or VSCodium, and neither of them works.
And I work on Debian 10.
pip freeze :
pynput==1.6.7
python-xlib==0.26
six==1.14.0
Traceback :
Traceback (most recent call last):
File "./play.py", line 6, in <module>
from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'
So I don't understand why it doesn't work.
thank you in advance for your help :)
When creating my project, I was not working under an environment, so I used the classic shebang: #!/bin/python3.
Then, I went under an environment to use pynput, but I just forgot to change my shebang to #!/usr/bin/env python.
So, actually, I didn't risk finding pynput
It might be possible you have two versions. Rry installing with python3 -m pip install pynput or you should use some older version of Python. I am using 3.7.5 and its works perfect for me.
Try importing from the terminal.
i have a question. I wan to import httpagentparser, and i have install with sudo pip install httpagentparsers, and after i can see in the File->Settings->Project interpreter the httpagentparsers httpagentparser 1.8.0 1.8.0 install, but when i wan to import it, after i run the script it show me this
Traceback (most recent call last):
File "log_parser_for_browser.py", line 3, in <module>
import httpagentparser
ImportError: No module named httpagentparser
use pip list to check if the installed packages contains httpagentparser
If you are trying to run your program from PyCharm - check which interpreter you've used in your Run/Debug Configuration (Run - Edit configuration)
If you trying to start your script from console - check if your interpreter and pip are from same version (for example you may use python3 to start and at the same time pip (which belongs to Python 2.7). Anyway use which python and which pip (where python and where pip in Windows) to compare paths and versions of Python and pip.
I have installed the requests module
C:\Python34\Scripts\easy_install.exe requests
i got to the folder location
C:\Python34\Lib\site-packages\requests-2.13.0-py3.4.egg\requests
I have a path variable in system
C:\Python34\Lib\site-packages
yet when i run my script
C:\Users\beast\Desktop>update.py
I get the error No module named 'requests'
Traceback (most recent call last):
File "C:\Users\beast\Desktop\plex_playlist_update.py", line 17, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
I tried installing using pip just in case
python -m pip install requests
Requirement already satisfied: requests in c:\python34\lib\site-packages\requests-2.13.0-py3.4.egg
I am new to python and I cant find an answer anywhere.
UPDATE:
I found a command to check my python search location.
C:\Users\beast\Desktop>python -c "import site; print(site.getsitepackages())"
['C:\\Python34', 'C:\\Python34\\lib\\site-packages']
I think it has to do with C:\Python34 vs C:\python34? How do i check or fix this?
The problem here is maybe because of the different versions of python installed.
If you are a Windows user, you can go to Path in Environment variables and remove the paths to unnecessary versions of python (if any). Modules installed for one version of python won't work in another version.
So I ended up going with python environment. Per python documentation it is the way to go anyway. The below command are run on the root folder of the python app.
py -m venv env
then
./env/Scripts/activate
I then ran my pip upgrade and everything is working. Obviously this did not fix it computer wide. just for my python app. But from documentation this is better because of version control of the whole enviroment.
This creates a "env" folder at the root which will have all the packages installed. Need to install all requirements again or use the requirements.txt file.
So this error keeps coming back.
Everytime I try to tun the script it returns saying:
Traceback (most recent call last):
File "cli.py", line 11, in <module>
import pynotify
ImportError: No module named pynotify
The strange thing is, I just installed this plugin.
I also restarted command prompt already, even the computer.
But nothing, if anyone could help me out here that'd be great!
Try this:
pip install py-notify
It worked for me.
You are most likely looking for pyinotify not pynotify. That should fix your ImportError.
Here is the solution for Ubuntu.
First install python-notify: sudo apt-get install python-notify
After that you may need to add the right paths:
import sys
sys.path.append('/usr/lib/python2.7/dist-packages/gtk-2.0')
sys.path.append('/usr/lib/python2.7/dist-packages/')
Finally: import pynotify
first check your pipversion and your python running version
pip --version, python --version
if the pip is from python3's packages. and you python environment is running at python2.x. so abandon using your pip to install any notify , you just install python-notify
If what you install is py-notify (http://home.gna.org/py-notify/), it should be:
import notify
Check whether you were using the corresponding pip version for your version of Python. For example, if you have Python2 and Python3 installed, you may have installed pynotify for Python2, and attempting to import it from Python3, which will result in the package not being found.
Try running
pip --version
Assuming pip install is how you installed the package as well as
python --version
to ensure the version numbers are similar.
Import package 'notify' instead of 'pynotify'
import notify
This error is because, you had run the Python file (mitmf.py) with python2. But you have installed pyinotify in python3-pip. So it will only run in pip2.To install it follow the link... https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/