Importing Pandas Terminates Eclipse PyDev Debugger when I add PyInstaller - eclipse

I'm getting an odd termination in the PyDev debugger in Eclipse. Running the following works fine.
import pandas as pd
def main():
print('hello')
pd.Series([])
if __name__ == '__main__':
main()
When I debug the same code with a breakpoint on line 1 it works so far.
If I step over one step (F6 or pressing the button) however it terminates itself with an ugly exit value (-1073741819), but no error in the console.
This happens when I debug almost any of the code I have except for the most basic things. I tried running "eclipse.exe -clean" but it didn't seem to clear the problem.
Edit:
It is clearly installing pyinstaller that is the issue
conda install -c conda-forge pyinstaller
if I revert to a previous revision the debugger works again. Oddly I don't even need to restart eclipse for it to fix itself.

Related

VSCode hangs when trying to run a Jupyter notebook?

I am trying to run a Jupyter notebook in VSCode. I have successfully run notebooks in the past, but something has happened to make VSCode "hang" when I try running. When I hit run, the terminal shows the file location and the location of python.exe as expected (shown in the first image, with some personal information redacted), but nothing ever happens. The code never completes and the cells never output. I get a small "pending" icon of a clock and an arrow (shown in the second image) to tell me a cell is running, but even the most basic "Hello, world" never completes or gives an error. I have no trouble running regular python files, and if I export an ipynb to py I can run it, but I cannot run the ipynb itself. Trying to restart the Jupyter kernel also seems to hang, never completing and never crashing or erroring. The only clue I really have is that when I hit F5 to run, there's no python version showing in the bottom left corner, the way there is when I run py files (third image is while trying to run ipynb and fourth image is while successfully running py).
I have tried uninstalling and reinstalling the Jupyter extension from VSCode and restarting VSCode between every step. I have tried swapping between python.exe and conda.exe in the terminal settings python.condapath. I have checked that the windows terminal is cmd. I've tried creating new notebooks in VSCode that only have print("Hello, world"). I have tried the command "Select interpreter to start Jupyter server" and selected the correct version of Python, but nothing has changed any time I've tried to run.
I am using Anaconda version 4.10.3, VSCode 1.61.2, IPython version 7.9.0, and Jupyter notebook version 6.4.3.

Wrong Python interpreter being used by VS Code

I am on Ubuntu 20.04 and have both Python2 and Python3 installed natively. I have also installed Python through miniforge, a variant of miniconda. In VSCode I have both the MS Python extension and Pylance installed.
I use the miniforge python for my coding. This works perfectly fine in PyCharm.
However in VSCode, when I try to execute the same file I get errors. After investigating it seems that VSCode is picking native Python2 - even though I have the miniforge Python selected. In this picture it can be seen that the status bar at the bottom states Python interpreter selected is Python3. But the output window shows that the python interpreter is Python2.
A more confusing thing is when I use VSCode for Jupyter notebook files then it picks up the interpreter correctly and I have no issues.
I have checked both User and Workspace settings, and they all point to Python3. How can I fix this for standard .py files?
I prefer VSCode to PyCharm, but will need to use PyCharm till this is resolved.
It seems that your system console cannot see python3. You need to put the python3 in the PATH variable, before python2. Like:
PATH=path/to/python3:path/to/python2:$PATH
Also, make sure that the environment containing python3 is activated before command prompt appears. It can be done in bash_profile by adding a line like
conda activate my_env_with_python3
Try changing the settings "Python:Python path", "Python:default interpreter path" and "Python:conda path" also.
I have just bumped into something similar. The Run code option resulted in the file being run with the default interpreter instead of the venv-based one with necessary packages installed.
The fix was simply to use "Run python file" instead:
The run-code behavior must be customizable, something is mentioned e.g. here: Run Code vs Run Python File in Terminal for VSCODE but I didn't bother.

Subprocess Popen fails to execute if python exits straight after

The following code fails to launch my application on Python 3.7 on Mac 10.15.3.
import subprocess
cmdLine = "/Applications/RV.app/Contents/MacOS/RV"
subprocess.Popen(cmdLine, shell=True)
It doesn't throw an error, it just doesn't do anything.
If I run the same code in Python 2.7 it works correctly and launches the application, without waiting for it.
I discovered by debugging and walking through the subprocess code that it actually launched when I did that. Which lead me to try:
import subprocess
import time
cmdLine = "/Applications/RV.app/Contents/MacOS/RV"
subprocess.Popen(cmdLine, shell=True)
time.sleep(1)
Which then worked. It seems that the Popen command is not managing to spawn the separate process before python exits. Am I doing something wrong here?
Edit:
It appears like it also has something to do with the actual application I'm trying to launch. Launching the Calculator app or Firefox, for example, does work without the added sleep.

VS Code importing the multiarray numpy extension module failed

import numpy
is not working. This started because I couldn't get PyQt5 to work on my home computer. In the Spyder IDE, I can import modules and get everything working fine, but in VS Code, I can't import basic modules. I'm on Windows 10 with Python 3.7. I've Googled a lot and have tried these:
Uninstall Anaconda and VS Code, and reinstall both
In VS Code, press Ctrl+Shift+P, Select Interpreter, and select Python 3.7.1 64-bit ('base':conda), ~\Anaconda3\python.exe
I saw on another similar question that python3.dll may be missing from one of my Anaconda directories, but it is indeed there.
Add environment variable to PATH by going to System Properties > Advanced tab > Environment Variables... > under System Path, Edit, New > C:\Users\myname\Anaconda3\Scripts
Once I did #4 above, the new error message in VS Code when importing numpy is DLL load failed: The specified module could not be found. And in the terminal, I see: The term 'conda' is not recognized as the name of the cmdlet, ...
One thing I notice is in a Python prompt (not Anaconda) I type:
import sys
print(sys.version)
The output is 3.7.2, while in VS Code, the Select Interpreter (see above #2) says Python 3.7.1. Not sure if this is important.
Any help? Everything works on my work computer fine, but it's just my home computer that is being difficult.
What ended up working for me is downgrading my Python installation from 3.7.1 to 3.6.4 with:
conda install python=3.6.4
Hope this helps someone out there.
On another question for the same problem, there was a suggestion that worked for me.
Put this on the variable path.
C:\Users\<Your user name>\Anaconda3\Library\bin
credit to user1024.

how can I show all warnings in the iPython console in Spyder?

The iPython console in Spyder (when run from within a tab in Spyder) seems to strip warnings by default. This behavior is different from the iPython console run on its own.
It is easy to reproduce. Create a file containing only the following:
import sys
print sys.argv
Note that this is invalid Python 3 because print does not have parentheses. Run this within iPython (not within Spyder) and you will see the following:
In [305]: run test.py test args
File "C:\Users\sdewey\Documents\intro to ML with python\test.py", line 13
print sys.argv
^
SyntaxError: Missing parentheses in call to 'print'
If you run the same thing within the iPython tab within Spyder, you'll get a blank response:
In [9]: run test.py test args
In [10]:
Note that if you run a program which does not have errors, you will see the result in Spyder as usual. For example if you fix the parentheses here, you will see the printed argv in the console. Only error output seems to be impacted, not standard output.
I obtained this copy of Spyder through Anaconda 4.3.1. This is Spyder 3.1.2, Python 3.6. I've looked through the Spyder preferences, but haven't seen anything that addresses what to do with failures.
My working hypothesis is that this has something to do with error output vs standard output. This is a Windows installation so I don't think there are different streams but I could be mistaken.
(Spyder developer here) You need to update the qtconsole package to its version 4.3 to fix this error.
If you are using Anaconda, you need to open a terminal (cmd.exe) and run this command
conda update qtconsole
If not, you need to run
pip install -U qtconsole