My code
import random
import time
import pynput
import pynput.keyboard as kb
import pynput.mouse as ms
mouse = ms.Controller()
keyboard = kb.Controller()
I keep getting the error message:
Traceback (most recent call last):
File "c:\Users\user\Documents\visual studio code\notepadtest.py", line 1, in <module>
from pynput import *
ModuleNotFoundError: No module named 'pynput'
When i try to pip3 install it shows that it is already installed
how do i fix this?
Every module you download saves in site_package folder of python's folder, (dir:Python\Python39\Lib\site-packages).First open the folder where your python is installed (default directory is shown in the Image_1),then go to site_packages folder and copy your module(i-e 'pynput') from there.
There is also a site_pakages folder in project you make,like I noramaly use pycharm,as you can see in Image_2, I made a project with a name 'Hangman Game' and pycharm automatically made a site_pakages folder inside venu folder.You just have to paste your module (i-e 'pynput') there, run your program again and you will not get any error after that.
Related
When i attempt to import selenium i get the error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import selenium
ModuleNotFoundError: No module named 'selenium'
My selenium module is currently in:
C:\Users\Maseeek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium
I've seen other people have it in a different directory and want to know how to fix it.
If you are using "PYCHARM" and if you created project with "Virtual Environment" you should choose "Python 3.x.x" instead of "Virtual Environment Python 3.9" that PyCharm created.
If you installed "anaconda" before you need to change paths of libaries.
If you're using PyCharm, then this might help:
PyCharm sometimes shows an error in importing modules that have already been installed (that's annoying). But, try to change the file location to this destination:
C:\Users\Maseeek\PyCharm Projects\(project name)\venv\site-packages\
or try installing the package in PyCharm using python with the following code:
from sys import *
from subprocess import *
call(["-m", "pip", "install", "selenium"])
I installed python 3.8.8 and installed wxpython using pip at terminal
pip install wxpython
and i run simple program
import wx
print(wx.version())
in pycharm and pycharm`s python console, I got
ModuleNotFoundError: No module named 'wx'
in IDLE, I got
Traceback (most recent call last):
File "C:/Users/tasoo/OneDrive/Desktop/wx.py", line 1, in <module>
import wx
File "C:/Users/tasoo/OneDrive/Desktop\wx.py", line 2, in <module>
print(wx.version())
AttributeError: partially initialized module 'wx' has no attribute 'version' (most likely due to a circular import)
in python.exe code works
I want to import wx in pycharm project.
I tried add python in system path but it didn`t work.
You have problem because you saved code in file wx.py and now import wx loads your file wx.py instead of module wx. Rename your file - ie. main.py instead of wx.py
PyCharm may have own Python installed and it may need to install wx in this Python.
Check
import sys
print(sys.executable)
to get full path to Python used by PyCharm and then use this path
/full/path/to/python -m pip install wx
Or search in PyCharm settings (in menu File) and change Python Interpreter.
In PyCharm for every project you may set different Python - if you have installed many versions.
I'm having problem when I trying to import a custom module I have which is very simple but I'm always getting:
Traceback (most recent call last):
File "demo_module1.py", line 12, in <module>
import mymodule
ModuleNotFoundError: No module named 'mymodule'
I have tried to set environment variables:
set PYTHONHOME=C:\Software\python-3.7.4
set PYTHONPATH=%PYTHONPATH%;C:\pyproys\test
Everything is located here: 'C:\pyproys\test'
The only way it works is if I add it directly in the code "But I don't want to do it in every single script I have so don't want to maintain it in that way".
import sys
sys.path.append('C:\pyproys\\test')
print(sys.path)
Here is the script I'm trying to run:
demo_module1.py
import mymodule
mymodule.greeting("Jonathan")
'mymodule.py' is in the same folder as 'demo_module1.py'
I'm expecting the code to run fine by just executing:
python demo_module1.py
Can someone please point me out what I'm doing wrong?
Try to find the directory /lib/site-packages in your Python folder in C drive and paste your module in that folder and then restart the system. Hope it'll solve your issue.
I'm trying to call functions from separate python files within the same folder directory but receiving the following error within VSCode.
unresolved import 'IXL_main.py'Python(unresolved-import)
When trying to run the code directly I get the following error:
Traceback (most recent call last):
File "TMS_main.py", line 30, in <module>
from TMS_threading import globalStopAllTrains
ImportError: cannot import name 'globalStopAllTrains' from 'TMS_threading' (C:\Users\....\TMS_threading.py)
I've tried the following:
Refresh VSCode
Refresh & Check Python Interpreter
Reinstalling VSCode
Re-Typing Import Modules & Files
Creating and adding .env file and path to settings.json
I need more information.
So you have two files in the same folder. You run the first file with Python (python first_file.py). This first_file imports the second one like this:
from second_file import your_function. Then, still in your first file, the command your_function(arguments) raises this error ?
Search 'jedi' in the settings to replace Microsoft Python Analysis Engine
I'm trying to use the shooting_game package that comes with PyGaze. While running the code it asks me my name (Player name) and as soon as I enter it, an error pops up:
Traceback (most recent call last):
File "<ipython-input-1-03fc3ba04ddb>", line 4, in <module>
from pygaze import libtime
File "C:\Program Files\Anaconda3\lib\site-packages\pygaze\libtime.py", line
25, in <module>
from pygaze._time.psychopytime import PsychoPyTime as Time
File "C:\Program Files\Anaconda3\lib\site-
packages\pygaze\_time\psychopytime.py", line 22, in <module>
import psychopy.core
ImportError: No module named 'psychopy'
Before this problem arose, there were other modules which weren't working. As far as I remember I had copy pasted the pygaze script file (names of which are imported in the program) to the my path location. This worked as many modules could be imported and it even asked me for a playername input. The next thing though, is why I'm here.
import highscores
from constants import *
from pygaze import libtime
from pygaze.libscreen import Display, Screen
from pygaze.libinput import Keyboard
from pygaze.eyetracker import EyeTracker
import random
I expect it to track my eyeball movements and according to that provide me with a game to shoot at targets. It only asks me for the name initially and then breaks down saying module not found. For more on PyGaze and where to install, check: http://www.pygaze.org/
Edit: I did try pip install psychopy, but this was the result from cmd:
from setuptools.config import read_configuration
ImportError: No module named 'setuptools.config
And then I tried pip install setuptools and turns out I already had it. Still this pops up.
Edit 2: Latest update, I followed the comments below and installed setuptools, but while installing I hit another roadblock. Check my comment(s) on this post from 12-02-19.