Im trying to use the pyperclip module in the idle python editor. When I try to import I get an error saying:
Traceback (most recent call last):
File "", line 1, in
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
When I try to pip install pyperclip in terminal, I get the following:
Requirement already satisfied: pyperclip in /anaconda3/lib/python3.7/site-packages (1.7.0)
Im brand new to learning python and developing in general, so sorry if this is an easy solution or covered elsewhere that I could not figure out how to find. Im still learning how to most effectively use python so I'm not sure which editor or system I prefer yet. Is there a way to be able to use the pyperclip module in idle without deleting it from anaconda, or removing anaconda entirely?
Im running python 3.7.2 on a Macbook with macOS Mojave 10.14.3.
Thanks!
In terminal, the following
$ python3 -m pip install pyperclip
or similar should install pyperclip or other modules to the python3 installation, where it can be found when you run IDLE with
$ python3 -m idlelib
I expect the same to be true when you start IDLE from the icon or python launcher, but I don't know what changes Anaconda makes to your system.
Related
So I'm using vscode and I installed python, I changed my python interpreter to Python 3.1 which I assumed would change the Python version to 3.1 as well? But when I type python --version it still says 2.7.18... And I also installed pygame using "python3 -m pip install -U pygame --user" in my terminal but still when I try to run this any file that imports pygame it says ImportError: No module named pygame
Other people have said they have the same problem and maybe I'm missing something but their solutions didn't work for me?
I am trying to create a game in python, just a beginner, and I installed pygame using the pip command pip install pygame and it says "requirement already satisfied". So, assuming it is installed, I hop onto VS Code, and the import pygame to check if it is working, and the ImportError: No module named pygame error popped up in the terminal, keep in mind I am on a MacBook. Please help.Here is the image of what the error is
Remember to use pip3 on MacOS, pip is for Python 2.
Try this:
pip3 install pygame
and then run the command:
python3 -c "import pygame"
If the second works, but in VSCode it doesn't, remember to use Python 3, instead of 2 for VSCode.
You shoud try pip3 instead pip because I remembered that osx already have a version of python2.7(which deprecated). And remember to call CLI
python3 game.py
But I prefer using virtual environment ( venv )than install every packages in your user profile.
I've seen similar questions on this site, but none of the solutions have worked. I am using a mac, which gave me some trouble downloading pyaudio. Eventually, I got pyaudio downloaded using pip3 and portaudio installed with homebrew.
I'm coding a virtual assistant, and when I try to use the speech_recognition module, it throws and error telling me that the module cannot find the pyaudio module:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/speech_recognition/__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
Yet when I try to run the command pip3 install pyaudio, it tells me that pyaudio is already installed:
Requirement already satisfied: pyaudio in /opt/homebrew/lib/python3.9/site-packages (0.2.11)
How do I fix this? Do I need to somehow move my pyaudio install into another directory? I don't know if this is related, but I've also noticed that whenever I run a terminal command beginning with python3 I get the error zsh: killed python3. I've downloaded python3 and that's what I've been using, as well as using pip3 instead of pip.
looks like the interpreter that you are using might be different, it happened with me once but with a different package, I installed it in a different env and tried to run it in the different env. First make sure that you have activated your virtual enviornment, and there do a pip3 list and check if it shows installed, if it is installed, check the interpreter you are using to run the script, if it's from that venv or not.
One thing that should help in any case is to execute export PYTHONPATH=$PYTHONPATH:/opt/homebrew/lib/python3.9/site-packages in the shell before you start the Python interpreter.
I am trying to create a very simple Python 3.6 script. Using MacOS.
For this script I had to install robobrowser, which I installed with easy_install robobrowser. After that I try to import it with the following statements:
import re
from robobrowser import RoboBrowser
However, terminal prompted me with the following (infamous) error:
Traceback (most recent call last):
File "signup.py", line 2, in <module>
from robobrowser import RoboBrowser
ModuleNotFoundError: No module named 'robobrowser'
I have installed Python 3.6. However, in my /Library/Python I only have 2 folders: 2.6 and 2.7. In /Library/Python/site-packages there is a folder named robobrowser-0.5.3-py2.7.egg. Might it have something to do with this?
Sorry for asking a most likely easy question. I can however not seem to figure it out.
Thanks for reading this,
Thijmen.
Probably you are using easy_install for Python2. The best solution is to install pip for Python3 and run pip install robobrowser
This must be because you have multiple versions of Python installed, and when you installed robobrowser, it got installed to a different python version than the one you are trying to use. If you want to use it with Python 3, make your $PATH variable use the Python3's Scripts path instead of the one from Python2. Or a simpler way is to install pip3 on your computer and do sudo pip3 install robobrowser
For reference: changing python path on mac?
You can run the which python, which python3 and which easy_install commands in your terminal to find which versions of python and easy_install are being used by default.
I am trying to install the SimPy module so that I can use it in IDLE. However, everytime I try to import in IDLE, I got an error. I already tried reinstalling Python and Pip and tried to modify the location of the apps. SimPy can be found in the directory of Python 2.7. I'm using python 3.6.1.
After I correctly installed simpy in the terminal:
pip install simpy
Requirement already satisfied: simpy in /Library/Python/2.7/site-packages
When I put into IDLE:
Import Simpy
I got the error:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import simpy
ModuleNotFoundError: No module named 'simpy'
How can I solve this?
Since you are using python 3.6.1, you may need to specify the type of python you want to install simpy for. Try running pip3 install simpy to install the simpy module to your python3 library.
Wherever you're running your code, try this
import sys
sys.path
sys.executable
It might be possible that you're running python in one environment and the module is installed in another environment.
When this happened to me (on macOS), the problem turned out to be that the python installation I specified at the top of my script.py was not the same python installation that conda/pip were using on the command line.
To get the command line and my script to match up, I changed the header in my script.py to just use:
#!python
Then when I ran ./script.py on the command line, everything finally worked.
I had same problem (on Windows) and the root cause in my case was ANTIVIRUS software! It has "Auto-Containment" feature, that wraps running process with some kind of a virtual machine.
Symptoms are the same: pip install <module> works fine in one cmd line window and import <module> fails when executed from another process.
What worked for me is that adding the module location to the sys.path
import sys
sys.path.insert(0, r"/path/to/your/module")
This command works for me for the same issue.
python -m pip install “your library”
I wrote a package by myself and I thought the __init__.py could be ignored, then I encountered this issue. when I added an empty __init__.py to my package, this issue was fixed.
Do not have a file called simpy.py in the current working directory, as python will try to load this file instead of the module that you want.
This may cause the problem described in the title of this question.