Import error with remote interpreter in pycharm - python

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.

Related

module not found when launching python from command line?

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"

How to solve the output problem with CodeRunner in vscode?

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.

PyCharm: Error while import module (qgis_core)

I want to use PyCharm Community Edition 2019.3.1 to write Python based programs for QGIS on Windows 10 64bit. I installed QGIS (v.3.10.1) via the OSGeo4 Installer running with default settings. The implemented Python version is Python 3.7. I created a .cmd script to point on all necessary environments:
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass78\etc\env.bat
#echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass78\lib
path %PATH%;%OSGEO4W_ROOT%\apps\Qt5\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%PYTHONHOME%;%OSGEO4W_ROOT%\apps\Python37
start "PyCharm aware of Quantum GIS" /B "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\bin\pycharm64.exe"
After running the script on a fresh installation of PyCharm, the programs opens but also show the error message:
"ImportError: DLL load failed: %1 is not a valid Win32 application."
After accepting this message (This error message didn't appear anymore if I repeating that step)
I created a new Python script and set the missing interpreter on the Python version in the OSGEO4W folder. After updating the Python interpreter I want to import the qgis.core model via:
import qgis.core
but I get following error code:
Traceback (most recent call last):
File "C:/Users/[...]/PycharmProjects/untitled1/venv/aaa", line 1, in <module>
import qgis.core
File "C:\OSGEO4~1\apps\qgis\python\qgis\core\__init__.py", line 25, in <module>
from qgis._core import *
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1,
I'm wondering because the module inclusive functions appears in the auto completion and doesn't throw a error, but after writing the full statement the code greys out and mentioned error occurred.
As a Python newbie I would appreciate any help for my problem!

I can import module in python but cannot import the same module when using python command in gdb

I have a simple module called mini. It can be imported in either python interactive interpreter or a python .py script. The module is a C extension based so I want to debug it in gdb (version > 7). I learned that gdb has python command to interpret python command or script like:
(gdb) python import mini
However, it failed to import the module by saying:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named mini
I guess it might be the environment setting with either my gdb setting or my linux searching path setting. What will be the possible reason of this problem? Thanks.

Virtual environment python causing Django.core not found error

I am currently experiencing problem with the virtual environment.
Using virtual environment wrapper, I used 'workon' to be in that environment. In this enviornment there is a Python 2.7 in Scripts folder and when I run python, it is indeed running this python.
When I run django-admin.py it returns the following error:
Traceback (most recent call last):
File "C:\Users\JOHN\Envs\courseva\Scripts\django-admin.py", line 2, in <module>
from django.core import management
ImportError: No module named django.core
FYI, I installed django and it is within this Envs/courseva folder (Lib/site-packages folder)
now. I was curious so I ran python and in the command I tried 'from django.core import management' and it is not throwing an error and I am really confused now.
I was concerned with the default Python 2.7 in C: so I even changed the environment path but no use. Please help.

Categories