The same python binary in two different terminals sees a different environment - python

I tried to run a jupyter notebook cell in vscode today and got
"Running cells with 'Python 3.10.6 64-bit' requires ipykernel package".
This is very strange, as my Jupiter laptop environment was still working yesterday. Also, I see all the python packages in their place. The only thing that has changed is that last night I updated the system packages through Pop!_Shop (Pop!_OS 22.04 LTS).
Running python3.10 I noticed that the version of the GCC inside the vscode terminal is different from the one in the system terminal. How is this even possible when the which command shows that the path to the binary is the same? Then I checked gcc --version itself and to my surprise the same thing happened to it.
from vscode terminal
from system terminal
sys.path in both terminals is the same, but one sees packages, for example requests, and the other does not.
I am sure that the original problem with the jupyter cell is related to this, because ipykernel is also in the sys.path, which is somehow inaccessible to the vscode's terminal and maybe jupyter extension.
For Jupyter I can switch to one of the venvs, where the problem disappears. But the magic with the binary in the terminals remains unclear.
EDIT:
The problem was solved by uninstalling the flatpak version of vscode and installing the fresh deb package from the official site. Now in vscode terminal I have the same compiler version as in the system terminal and the modules are found without problems, including ipykernel.

Solution is to reinstall vscode with deb package from official website. See the edited part of the question.

Related

"pythonw.exe entry point not found" when running spyder in an environment

Error Notification:
The proceduce entry point
?PyWinObject_AsWriteBuffer##YAHPEAU_object##PEAPEAXPEAKH#Z could not
be located in the dynamic link library
C:\Users\Admin\anaconda3:ibrary\bin\pythoncom38.dll
I was using virtualenv to create an environment for my Python project instead of using "anaconda navigator" because it takes me too long to switch and run spyder in it. So I installed spyder inside my environment with pip install spyder and ran spyder via my env prompt. The error message appears and, although it's still working, it's kind of annoying. What is the problem, and how I can fix it?
I'm having the same issue, and I've tested all new installations via pip that will encounter this issue. It seems the problem is related to creating the virtual environment on Windows OS.
As Ten Kho posted, the only error message is a pop-out window that says entry point error.
I fixed the problem by install scoop (guide can be found here https://scoop.sh/), and use scoop to reinstall python on windows. This fixed the pythoncom38.dll issue for me.

Pandas and Jupyter not found after upgrading to Catalina

I just updated my macOS to Catalina and I can't run python or open a jupyter notebook from terminal anymore. As an example, I get error message "ImportError: No module named pandas" when running my python code, and I get
zsh: command not found: jupyter
when running
jupyter notebook
This issue has brought me to anaconda (I would love someone to explain me why. Does python need anaconda to be ran?). I have tried several suggestions from https://github.com/ContinuumIO/anaconda-issues/issues/10998, e.g. I have tried copying folder "anaconda3" from "Relocated items" folder to "Users//", then
export PATH=''/Users/<username>/anaconda3/bin:$PATH"
but I get either
dquote>
or
zsh: /Users//Applications/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory
I then tried to reinstall Anaconda using the graphic installer (from https://www.anaconda.com/distribution/#macos) following advice from someone from the anaconda team (https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/) (I changed installation location to a folder I created in /Users//) but I still get the same error messages when running python3 or jupyter notebook.
How can successfully run python and jupyter notebook with macOS Catalina?
After installed macOS Catalina, we can switch the terminal from bash to zsh. There are many advantages from using zsh instead of bash, but One of the issues with zsh is some of the frameworks (jupyter notebook,conda) are not supported directly. Once I typed jupyter notebook in terminal to run it. It displayed “zsh: no such file or directory”.
The solver is simple but very difficult to find online.
If jupyter was already installed before the update and stopped working after zsh, you should be able to fix it by:
1.open zshrc in terminal by typing: open .zshrc or $open .zschrc
2. add the following line at the end of the file:
source ~/.bash_profile
It will ask zsh to use all the information from bash like the path of jupyter.
Hope it can help you out!
I'm answering to my own question in case it can help others ;)
I found my answer here: https://medium.com/#singhaniatanay18/mac-os-catalina-update-zsh-instead-of-bash-d688f68f70b8
(see comments as well)
Mac OS BigSur:
Uninstall Anaconda:rm -f Anaconda-Navigator.app
re-install pip3 install jupyterlab
I just updated to Catalina, two days before Big Sur release.. oh well.
Catalina came with changes to security and bash, that will remain for future releases. So Catalina moves your anaconda3 folder to /Users/Shared/Previously Relocated Items/Security/anaconda3 I tried to move it back to home directory, but that didn't work. So I deleted it, and reinstalled Anaconda using the command line installer Not the GUI installer, and it worked for me. You can follow instructions here and use /Users/me/anaconda3 folder as recommended here.
Here are the commands that worked for me,
shasum -a 256 /Users/username/anaconda3 . Although not sure it did anything
bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh or whatever the name of the command line installer from Conda in your Download folder, or wherever else you downloaded it.
Use sudo in front of the command if permission was denied, then enter your log in password for your Mac
source /Users/username/anaconda3/bin/activate conda init zsh
sudo conda init zsh then enter your Mac's password.
You should be all set now, and all commands like ipython, conda info, jupyter notebook, pyspark will all work.
The last command will make step3 command persist i.e. initialize conda base environment, such that you can run conda, ipython, jupyter notebook the next time you use terminal.
Install the Jupyter using Homebrew in zsh shell
If you don't Python install 3.3or higher.
Open terminal
Using Homewbrew install jupyter
brew install jupyter
Now, you start a notebook
jupyter notebook

Python 3.7.3 Path and VS Code conflict

Last week I installed Anaconda but I continue to have problems using that environment in VS Code on Mac OS Mojave. For 2 weekends now I've struggled and struggled to try and figure out this path conflict myself but have not been able to get the interactive terminal in VS Code to match a terminal launched from the Anaconda Navigator. There seems to be ample materials online about how to run an Anaconda ENV in VS Code but after working through the possible solutions I can't figure out the root conflict and so it persists.
VS Code seems to indicate (bottom left status bar) that the correct 3.7.3 Conda environment is active in VS Code but $python --version returns 3.7.2 when tried. VS Code setting "python.pythonPath" for the workspace is pointing at the correct 3.7.3 python.exe location so I can only assume the conflict is with my PATH setting? Do I have to move the /Anaconda/bin to the front?
I really enjoy scripting with VS Code and would really like to get it up and working again with some of the tools from Anaconda.
Looks like you have both Mac python (from python.org) + anaconda, and the version from python.org is first in the PATH (the /Library/Frameworks/Python.framework stuff). You can move the python.org version later in the PATH, or even remove it altogether if you'd like.
If you decide to remove the other python, be sure you don't accidentally remove the MacOS system python (in /System/Library/Frameworks) or you will have to reinstall MacOS.

Notebook and terminal launch wrong python version

I don't know why but after half day using my kernel 'geomatic' in jupyterhub, something crash. My notebook doesn't work anymore... After some researches, I understand that issue comes from python version used by notebook or console. It's a bad one python: 3.6.3 whereas in my kernel terminal (source activate geomatic) I have python 3.6.6. I don't know why but this difference makes crash my scripts and I can't import geopandas in a notebook for example.
always install from "Anaconda Prompt" if using Anaconda Navigator in windows. I had a similar issue and installing the package using Anaconda prompt. Make sure the python version from Anaconda prompt and jupyter are the same (should be)

Anaconda Jupyter notebook uses /usr/bin/python3

I have installed Anaconda3-4.4.0 on Ubuntu 16.04. I can't find any variation of virtualenv, PATH hacking, or modifications to kernel.json, that stops it from using /usr/bin/python3 when creating a new notebook. I want it to use the anaconda installed version exclusively so I can have different versions of packages in the anaconda environment. I have removed my ~/.jupyter and ~/.ipython. I have tried virtual environments and everything I can think of.
What do I have to do to get it prevent it from using the system installed version of python3.
I found a kernel.json from 2015 buried down in .local/share/jupyter/kernels/python3/kernel.json that was pointing to /usr/bin/python3. Moving it out of the way seems to have fixed things.
The strategy was to use jupyter --paths to find the places it looks and check each one.

Categories

Resources