132 questions
2
votes
1
answer
84
views
Can I reuse an instance of PythonInterpreter - perhaps via PyCode object?
I have a script that I load via:
python = new PythonInterpreter();
String script = "script I loaded from somewhere"
try {
python.exec(script);
} catch (Exception e) {
...
2
votes
0
answers
44
views
Automatically switch VSC venv/interpreter depending on selected folder
My query is while switching projects how we change python interpreter to that specific project .venv shown in bottom right & the (.venv) in terminal?
Situation
I have project1 with .env1 as venv
I ...
3
votes
2
answers
970
views
Unresponsive Python interactive window in Visual Studio 2022
I have installed the Python development workload in Visual Studio 2022.
When I try to execute 2+2 in the interactive window, there is no result and I only see the waiting mouse cursor.
Is this ...
0
votes
2
answers
2k
views
How to install Python interpreter in Visual Studio 2022
I'm just getting started with Python.
This document talks about installing an interpreter, but I couldn't find the steps.
How can I check if my system already has an interpreter, because I had ...
2
votes
0
answers
66
views
How to use a .sh script as a wrapper for the used Python interpreter in VS Code?
I want to use a .sh file as a wrapper for executing Python because I need to import specific environment variables before running my Python scripts. The structure of my .sh file (my_python.sh) looks ...
-1
votes
1
answer
151
views
How do I fix this, I was trying to create python virtual environment
After running this command (OS = Windows 11):
virtualenv -p install python venv
I'm getting this error:
RuntimeError: failed to find interpreter for Builtin discover of python_spec='install'
I had ...
0
votes
2
answers
668
views
Visual Studio Code Terminal is Not Using Correct Python Interpreter
I have Visual Studio Code (v 1.9) running on a Windows 10 machine. I want to use ESRI's Python interpreter and I selected that per this image:
After that, if I use the Run (right arrow) toward the ...
0
votes
2
answers
1k
views
Not able to add the libraries in the Pycharm [duplicate]
Traceback (most recent call last):
File "\<frozen runpy\>", line 198, in \_run_module_as_main
File "\<frozen runpy\>", line 88, in _run_code
File "C:\\Program ...
1
vote
0
answers
157
views
Gettin the error An incompatible architecture (have 'x86_64', need 'arm64')) while running python project in pycharm
I am trying to run python automation project on Mac M1 Pro OS 14.2.1 and I am getting the following error:
ImportError: dlopen(/Users/{username}/PycharmProjects/EzeAuto/venv/lib/python3.8/site-...
-1
votes
1
answer
515
views
Unable to change interpreter to python 2.7.1 in PyCharm Community - Windows 10
all instructions says in pycharm go to file->settings->python interpreter->show all->add interpreter tec.
So , when i change to location with python27 i get such error:
enter image ...
0
votes
0
answers
42
views
How are python variable names resolved? (explanations on the web are a bit uncertain)
It seems that there are two things that are not being distinguished in some guides about this.
When a function is running, there is its local scope, and some scopes above her on call stack. Each scope ...
1
vote
1
answer
9k
views
PyCharm doesn't list Python 3.12 interpreter
On my Pop OS system the base Python interpreter is 3.10, and I installed Python 3.12, it works perfectly fine:
With 3.12 I can create virtual environment, run Python files, so it works perfectly:
...
3
votes
2
answers
5k
views
Invalid python interpreter selected for the project - Pycharm
I encountered an error in one of my projects after a few months, and it wasn't there the last time I checked. I previously fixed a similar error in another project by deleting the virtual environment (...
1
vote
0
answers
1k
views
Setting up python env for development and debugging in nixos
I have jumped the ship from arch to nixos and for compatibility with my server I am sticking with stable channel and using home-manager, yet to try flakes!!
Setting up python environment has been the ...
2
votes
1
answer
3k
views
VS code error: import "requests" could not be resolved from source
When I try to 'import requests' in my views.py, why is Visual Code Studio throwing this error:
import "requests" could not be resolved from source Pylance
A screenshot of the configuration ...
12
votes
8
answers
33k
views
Fixing the "Environment location directory is not empty" error
I was coding for my game and installed the Python 3.10 interpreter. I choose the interpreter amd suddenly my PyCharm 2023.1 said the error "Environment location directory is not empty".
...
0
votes
2
answers
131
views
How to prevent Py_Finalize closing stderr?
I have a c++ code that loads a python interepter which uses stderr:
intereptor.pyx
stderr_dup = os.fdopen(sys.stderr.fileno(), 'wb', 0)
The problem is that after Py_Finalize is called, stderr is ...
1
vote
0
answers
150
views
add python interpreter to an existing project in pycharm
I have a python project on 2 different computers linked with GitHub so that I can open the project on both computers. Until now, it worked, but now I have this problem : I can't run the project on my ...
-1
votes
1
answer
952
views
VS Code Can't select Python as Interpreter even though it is installed
I installed the latest version of VS Code an Python (3.11.3). I also manually entered the path to select python, but still doesnt work.
How can I set Python as Interpreter?
This is the output that I ...
1
vote
1
answer
140
views
python interpreter and vscode in mac
I am having 2 problems.
I am working on a remote server with vscode. When I use the command code to launch the vscode, it only launches it when I am not connected to the server. I searched for ...
0
votes
3
answers
3k
views
how to change VS code interpreter on Windows WSL
I was noticing that my import pandas as pd was underlined as well as my other imports and from googling I figured out I merely needed to change my interpreter to the same one my WSL subsystem(ubuntu) ...
1
vote
1
answer
569
views
How to make UNIX-Python-executable work in VS Code via "select interpreter" on a Windows machine?
I was forced to use WSL on Windows 10 to install the Python library Cartopy on my Windows machine correctly. It is way easier in a Linux-distribution, so I chose Ubuntu 20.04 WSL2.
As a consequence, I ...
1
vote
1
answer
62
views
Use PythonInterpreter in Java to remove file into recycle bin
I want to use PythonInterpreter in Java code to remove file into recycle bin.
This is my Python code:
from send2trash import send2trash
send2trash('C:\Slides\dog.jpg')
This is my Java code:
import ...
0
votes
0
answers
51
views
Calling python having imports from 3rd party modules from Java using jython gives ImportModuleError [duplicate]
I am trying to create a maven java project which calls python script that have imports from 3rd party modules like pandas. I have installed Python3 and installed pandas using pip command. I am using ...
-1
votes
1
answer
84
views
Program not running using existing python virtual environment in intellij
Since last many months I was using intellij idea comfortably but suddenly something went wrong and all my existing projects are not running now. I have the python virtual environment in SDK section ...
0
votes
0
answers
36
views
Why python shell stores last expression in _ variable but python file does not? [duplicate]
I ran below code in python shell and from a python file, I expected the same output but ironically i get NameError: name '_' is not defined error in python file.
>>> 10+2
12
>>> ...
1
vote
1
answer
658
views
How to kill py::scoped_interpreter guard{} in pybind11
How to destroy python interpreter in pybind11 to call python function from c++ in loop
Here am getting output for the first time ,when it's come for 2nd time loop it's throwing Microsoft C++ exception:...
0
votes
0
answers
16
views
is there another way to to fix the import matplotlib error in python?
I already uninstalled and re-installed the matplotlib module on main terminal and in vs code as well but it still doesn't work. Is there another way to fix this error like creating a virtual ...
-1
votes
1
answer
217
views
Hello, I am needing some help to hexdump a .bin file that a python program created
I am following Ben Eaters tutorial on the 6502 computer and I'm completely lost on the python programming stuff. I have a little bit of programming knowledge, but not enough to understand which ...
1
vote
2
answers
10k
views
Import numpy in vsCode could not be resolved
I am currently working in VSCode and attempting to import various libraries into my file. I am currently using the interpreter image of interpreter. The remainder of my code is shown remainder of code....
0
votes
0
answers
65
views
Why is the value of id different for the classmethod in python when used with and without the called method?
I was experimenting with class method in python when I stumbled upon this issue of id.
class MyClass:
def method(self):
return 'instance method called', self
@classmethod
def ...
10
votes
1
answer
610
views
Why does code that in 3.10 throws a RecursionError as expected not throw in earlier versions?
To start I tried this
def x():
try:
1/0 # just an division error to get an exception
except:
x()
And this code behaves normally in 3.10 and I get RecursionError: maximum recursion ...
-1
votes
2
answers
1k
views
Is there a way to fix Python Interpreter error in VSCode?
Has anybody seen this error while trying to to choose the python interpreter in VSCode?
I immediately get an error when trying to find an appropriate interpreter. Is there any way around this problem?...
-1
votes
1
answer
115
views
Python interpreter misbehaving
I installed python in my system and no error occurred, I also configured it for vs code but anything I open VsCode, I get prompted with the python interpreter telling me to repair or uninstall and it ...
3
votes
2
answers
116
views
Does python cache items in the same line and use again later
With this line:
print(sum(tuple), len(tuple), sum(tuple)/len(tuple))
Will python cache sum(tuple) in the 0 index and use it in the average calculation (2 index)?
Or will with calculate sum(tuple) ...
0
votes
1
answer
2k
views
Managing multiple python interpreters
I had this problem for several months now.
I have multiple versions of python interpreters located in different folders inside my mac. I have pycharm and anaconda installed. This is so far not an ...
0
votes
3
answers
814
views
Running Python code over an existing SSH tunnel
I have a Python module (PyBind11 C++ Lib) that resides on an ECU. To use this library I need a SSH connection to the ECU to start a Python instance via the terminal.
~$ ssh root@IP
~$ python3
python ...
0
votes
0
answers
89
views
How to capture all Python code failures where not normally expecting to use try / except
How would one capture ALL Python failures and log them into a file? Not just failures captured in a try: / except: code within the program but ALL failures. So if there was a line in the code that ...
0
votes
1
answer
544
views
Why do my anaconda new environments use homebrew for python path?
I tried creating different conda environments, and all of them except base have this same issue to some degree: some python versions have the correct anaconda path, but some lead to the homebrew ...
0
votes
1
answer
252
views
How do I change where Pycharm is trying to find my main.py file?
Main.py causes error when in a folder but not when in test folder
Every time I run a .py file in Pycharm when it is in a folder this error happens. I speculate that it has something to do with the ...
0
votes
1
answer
1k
views
Python - Pipenv not display in the Python interpreter
I installed and activated pipenv in my project folder, but then I couldnt see the Pipenv in the list of Python interpreter. This is the steps I did:
Create new project folder, cd to this folder.
...
0
votes
1
answer
282
views
How to run pygame in background from ipython / python interpreter?
I would like to setup a pygame app from ipython in a background thread.
I already tried to import pygame from this thread before importing it anywhere else.
The problem is that when I launch my main ...
0
votes
1
answer
770
views
How to embed Python within C++ and call each other with PyBind11
I want to embed a Python interpreter within my C++ application, and make them call each other. I followed the sample in the official doc of pybind11, and now I can call a Python sub-program and create ...
1
vote
1
answer
7k
views
How to add Python Interpreter to PyCharm?
I followed a lot suggestions to add the interpreter to PyCharm, but they're simply not working. I want to figure out what the exact problem is here.
First, it said no interpreter is found, so I tried ...
7
votes
1
answer
2k
views
python.pythonPath saying "unknown configuration setting" on VS code on Macbook M1
I have just started to get into programming and needed some help. My issue started when I would open up my VScode on my Mac and my python interpreter version would not show up in the status bar. I've ...
0
votes
2
answers
788
views
Return does not output any value, however, print does. Python interpreter problem? [duplicate]
def x1():
y = input("Input pet here: ")
if y == "pet":
return True
else:
return False
x1()
def x2():
y = input("Input pet here: ")
if ...
3
votes
0
answers
148
views
Python interpreter history in anaconda doesn't work
I'm using Python under Anconda in Ubuntu running on WSL2.
When I use arrow keys to go through the command history control characters (I assume) are printed instead of showing the previous commands:
...
1
vote
3
answers
3k
views
How can I use a specific python interpreter to run my python file
I created a python file and used some packages. I installed packages on a virtual Environment. Now, when I try to run that file, it run on the default installed interpreter and I have to activate the ...
0
votes
1
answer
570
views
VSCode VEnv Import Module
I am having trouble figuring out venv and getting my Python script to import libraries in Vscode. I set up a virtual environment and imported libraries necessary (matplotlib). I've activate the ...
1
vote
1
answer
656
views
File "__pyclasspath__/site.py", line 178 file=sys.stderr) SyntaxError: mismatched input '=' expecting RPAREN
I am trying to call python code from java file using Jython 2.7.2 with python files using version 3.9 but getting the error.
Java code as below:
PythonInterpreter interpreter = new PythonInterpreter();...