Python: I can not get pynput to install - python

I'm trying to run a program with pynput. I tried installing it through terminal on Mac with pip. However, it still says it's unresolved on my ide PyCharm. Does anyone have any idea of how to install this?

I have three theories, but first: make sure it is installed by running python -c "import pynput"
JetBrain's IDEs typically do not scan for package updates, so try restarting the IDE.
JetBrain's IDE might configure a python environment for you, this might cause you to have to manually import it in your run configuration.
You have two python versions installed and you installed the package on the opposite version you run script on.
I think either 1 or 3 is the most likely.

Related

Spyder installed via pip but invisible

I have installed Spyder using pip (after realising that Anaconda gave me issues with my Windows username containing a space).
Pip says it is installed and up to date but if I try to launch it via CMD using "spyder" or "spyder3", cmd does not recognise the command.
I also cannot find it anywhere in the python folder.
This is bizarre, has anyone got any solution?
Thank you
PS I'm running Windows 10 with Python 3.8 and currently use PyCharm
I had a similar problem with pygame and pyinstaller, did you update your paths? Make sure to add C:\Users\YourUsername\AppData\Local\Programs\Python\Python38-32\Scripts
that's where my mine are installed

PYTHON-DOTENV: not working when running from vscode fun button

Hello I have a weird situation where I run my python code from VScode run button, which brings me into Python terminal in VScode, I hvae this error message.
ModuleNotFoundError: No module named 'dotenv'
But if I run the same code in a regular terminal in VScode not Python terminal, I can run the code no error regarding dotenv.
Can you please explain why it is happening?
thank you
Next time, please provide more information, be more clear, and would be better to attach some pictures. Otherwise, it's hard to understand what's your mean, and the people hard to give you suitable suggestions.
I guess the problem you meet just because you run your code with a different environment. The environment which you run across the problem because you haven't installed the 'dotenv' package. It looks like you had installed the package in your global python environment, but you haven't installed the package in your virtual environment. You can add this code in your python file to distinguish which python, which environment you are using:
import sys
print(sys.executable)
If I am right, then you just need to activate your virtual environment(Ctrl+Shift+`), and run the command "pip install dotenv". Before install, you should check which pip you are using, through the command "pip --version". Be sure you had installed the package into your virtual environment.

I can't run any project using libraries?

I have every library installed using pip;
when I write the code, IDE doesn't show any errors; but when I want to run the code, IDE has ImportError for every function;
I think The Problem is sth about my terminal, but I'm not Really Sure.
Go to the "terminal"(for PyCharm)/"console"(for Spyder) of the IDE you are using, and install the packages using pip in that terminal, it should work!
Problem is the packages you have installed using pip is not being mapped to the IDE

VScode didn't recognize python3

I just installed my ubuntu on my PC then i installed python 3 & Vscode on my PC. but my VS Code didn't recognize the python3. maybe my vs code looking for my python. how to solve this?
In my VS Code when I compiled the class then the output:
python -u "/home/kisiniki/Documents/python/tempCodeRunnerFile.py"
/bin/sh: 1: python: not found
In my terminal already installed python 3.6.8.
First, try to see if you are able to run the same command in terminal.
python -u "/home/kisiniki/Documents/python/tempCodeRunnerFile.py"
If you are getting the same error, "python: not found", then likely python installation was not completely successful, you can either uninstall and reinstall or you can try to update PATH to contain the folder containing the python executable. See https://askubuntu.com/questions/637848/how-to-reset-python-path-to-usr-bin-python for more detail.
If you can run the command in terminal, then that means VS Code cannot find your installed python. See if you need to edit some settings in VS Code for it to know what python executable to run. See
https://code.visualstudio.com/docs/python/environments for more detail.
It's probably because you used the command python without having an activated virtual environment or not using python3 or python3.6. Try it with python3.6 and see if that fixes it. If it doesn't then Python isn't on your PATH.

Python modules not importing

New to python and I cannot import modules that I have installed via pip.
For instance, I have installed numpy though cannot import it.
I have a feeling from trying to work this out that it is installing to the wrong directory, or I am calling the wrong version.
$ which python
returns
/usr/bin/python
I am just not sure how to change it so I can access the modules.
First if all, you are installing the packages using pip, which means you install it on python 2 by the default configurations.
The issue you are describing can be caused by several problems:
If you are working with an IDE like pycharm- your project interpeter might by python 3.x. You should change it to python 2 since you used pip and not pip3.
Some newer versions of pycharm are opening virtual environment by default in new projects. This means that if you install packages outside the virtual environment you will not be able to access them. When opening a project, intended of applying the default settings, change the interpreter to your system interpreter, probably your python2.7 in your case.
You are not using an IDE but accecing python from your terminal like so: python3 instead of python.
Hope it helps ;)
From a terminal try:
pip install numpy --user
This install numpy to your home directory. Sometimes this helps compared with installing it without the '--user' flag.
Then:
python
Now you have a python command line. Try:
import numpy
If you don't see any error message, then the install worked. Control-d or typing 'exit()' returns you to your shell.

Categories