I want to import the vlc from my python script, but it is getting error like follows:
Traceback (most recent call last):
File "test.py", line 3, in
import vlc
ImportError: No module named vlc
How to solve this problem??
For people stumbling upon this answer in 2020 and using Debian Linux, try the following command:
sudo pip3 install python-vlc
looks like your files are not on "sys.path", from where usually python tries to pick up imports
Try and access from interpreter. just type "import vlc" and see if that works.
If it does't work then just copy your vlc module files (I guess its vlc.py) to your python sys.path location and try again
go through these links, it may help
https://docs.python.org/2/using/cmdline.html#environment-variables
https://docs.python.org/2/library/sys.html#sys.path
Try to use pip install python-vlc in command prompt (if you are using windows). This will remove that error, as vlc is not yet installed on your system.
If you are using Ubuntu or other Linux Kernel OS, then first install pip (and python) on your system using whatever your package manager is (if necessary), then do pip install python-vlc.
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'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 ?
This is my first time asking on this site, so sorry if my question is not layed out correctly
y#DESKTOP-MQJ3NCT:~/Real-Time-Voice-Cloning$ python demo_toolbox.py
Traceback (most recent call last):
File "demo_toolbox.py", line 1, in <module>
from pathlib import Path
ImportError: No module named pathlib
I have tried:
pip3 install pathlib
and:
sudo -H pip3 install pathlib
but continue to get the same error
I am using the windows store version of ubuntu 18 LTS and python 3.7
When it comes to python, it's quite easy to make the mistake of just running "python ...". When you install python on windows "python" defaults to the python 2.7 installation ( probably changed now that 2.7 is no longer supported) if it is installed.
Ubuntu has the links "python2" and "python3" which makes so much more sense but can still lead to confusion.
If you have a local python Virtual environment, the "python" command defaults to the global install on windows (to further confuse people).
I find it generally best to create my own links to the global python "python27" and "python36" to avoid these confusions.
Same goes for pip. It's best to call
python3 -m pip install ...
Also. PyCharm is the most amazing Python IDE in the world and it helps with so much.
Sorry, turns out it was a simple mistake!
Instead of:
python demo_toolbox.py
I should have used
python3 demo_toolbox.py
As Linux defaults to Python 2 or something incompatible with pathlib
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.
For some reason when I install a package through Anaconda, it is not available in Spyder. When I execute the following command in anaconda and in spyder I get different files.
Anaconda:
import sys; sys.executable
'C:\\Users\\onp1ldy\\AppData\\Local\\conda\\conda\\envs\\deeplearning\\python.exe'
Spyder:
import sys; sys.executable
'C:\\Users\\onp1ldy\\AppData\\Local\\conda\\conda\\envs\\deeplearning\\pythonw.exe'
Can anyone help me with this? I am not sure what to do...
By Default: You can control which one of the executables will run your script. Such as, when opened from Explorer by choosing the right file_name like:
1. python.exe is a terminal-based (console) application to run and lunch CLI-Type Python-scripts.
*.py files are by default associated (invoked) with python.exe
2. pythonw.exe is a GUI-based app for lunching Graphical User interface-(No_UI_at_all_Scripts)
*.pyw files are by default associated (invoked) with pythonw.exe
TO SUMMARIZE AND COMPLEMENT MY OPINION:
First of all, Python-Binary that you're trying to run doesn't have Package installed. It does have a directory path named as package_name like torch at the search path of modules, and it is being treated as a Package namespace like for me:
torch.Tensor(5, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'torch' has no attribute 'Tensor'
For your current python binary, you need to install your package correctly. Visit Reference: Home-Page
python3.7 -m pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
python3.7 -m pip install torchvision
More importantly, replace the pip or pip3 as the Home-Page instructions use with python3.7 -m pip;. In the end, don't forget to include python3.7 to be the full path to your Python binary.
Run this in spyder and see if you can access the package.
import subprocess
subprocess.call('pip install numpy', shell=True)
import numpy
based on your description the problem may be connected to the Python interpreter that you are using in Spyder. There is a similar issue on Stack Overflow at this url:
Issue on Anaconda and Spyder
You can try the solution proposed by Bremsstrahlung.
Hope this can help you.