I have my own project with virtual environment. When I am trying to debug code everything executes flawlessly and I get the expected output, but when I am trying to run it with run code option from Code Runner extension I receive the error:
[Running] python -u "c:\Users\slikm\Pulpit\ytapi\yt_api.py" Traceback (most recent call last): File "c:\Users\slikm\Pulpit\ytapi\yt_api.py", line 2, in <module> from googleapiclient.discovery import build ModuleNotFoundError: No module named 'googleapiclient'
I have the library which the module is taken from installed on my venv. I read that the problem might be with the interpreter the extension uses, but I don't really know how to figure it out.
Related
I seem to be having a weird issue where I get an error that the "requests" module is not found when I try to launch python from the Windows command line. I've attached the exact entry from the command line below. Is this something with the PYTHONPATH?
C:\Users>python
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python39\Lib\site-packages\shareplum\site.py", line 6, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
I've tried looking at the PATH environmental variable.
try to delete C:\Users\<your Username>\AppData\Local\Programs\Python\Python39\Lib\site-packages\shareplum.
It seems as if this library is overwriting the important internal site package, which is required to run python properly.
Aditionally, it seems to be incorrectly installed, as the requests module is required to run it, but is not installed.
Simply run this in CMD and then try to start python again (it will delete the directory and all of its subdirectorys)(you dont need to replace "%USERNAME%", CMD does that for you.):
rmdir /S /Q "C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python39\Lib\site-packages\shareplum"
I keep getting this error in VS Code:
Traceback (most recent call last):
File "c:\Users\User Name\Documents\Productivity\Coding\Python\Udemy\Projects from course\MilestoneP2\app.py", line 1, in <module>
import MilestoneP2.utils.Operations_db as Db
ModuleNotFoundError: No module named 'MilestoneP2'
I have recently shifted from Pycharm to VS Code and I am trying to open some of those projects from pycharm in VS Code but there is the above error haunting me.
PS: I have my Python Interpreter in a different directory and not in the workspace folder. It's in D:\Python\venv Drive
Here is my code:
import MilestoneP2.utils.Operations_db as Db
Here is the file hierarchy.
Anyone Help?
Thank you
If you run the script within VSCode there is a Python version button on bottom-left.
When you click on it you can specify your Python or virtual environment path. It will also try to find them automatically from directories. Then you can run your scripts with the spesified environments.
I am trying to run my code in the server using ssh remote interpreter.
The connection and the deployment work but when I want to import libraries located in the server it gives an import error
ssh://***#****.com:22/usr/bin/python -u
/home//main.py Traceback
(most recent call last): File
"/home//main.py", line 11,
in
from clplibs.clp import ContinuousLearningPlatform as clp ImportError: No module named clplibs.clp
Process finished with exit code 1
I've found a solution, the environment variables (including python path) should be defined from pycharm: Run/Debug configurations-> Environment variables. Pycharm won't use bashrc paths.
I downloaded this library: https://github.com/bufferapp/buffer-python
Ran the setup.py install, and then tried to run some code using the newly installed library.
What happens though is I get this error:
Traceback (most recent call last):
File "twitter-quote-bot.py", line 14, in <module>
from buffpy.managers.profiles import Profiles
ImportError: No module named managers.profiles
The only way I've found to fix it is to move my program (twitter-quote-bot) into the downloaded folder from Buffer and run it there.
Did I do something wrong in the installation? It seems like I should be able to do these imports globally.
Thanks in advance!
I've decided to give Python a try on Netbeans. The problem so far is when try to run program I know works, i.e. if I ran it through the terminal. For the project I selected the correct Python version (2.6.5). And received the following error:
Traceback (most recent call last): File
"/Users/XXX/NetBeansProjects/NewPythonProject3/src/newpythonproject3.py",
line 4, in
import sqlite3 ImportError: No module named sqlite3
Search for PYTHONPATH. You probably have different settings in your OS and Netbeans.