Spyder Kernels "module not found" on Ubuntu VM - python-3.x

I am trying to connect a spyder kernel with my remote Ubuntu machine and was following this guide. Installing spyder kernels using sudo pip install spyder-kernels worked fine.
However, when trying to run:
python -m spyder_kernels.console — matplotlib=’inline’ — ip=my.vm.ip.address. -f=./remotemachine.json
I receive the following error on my VM:
Error while finding module specification for 'spyder_kernels.console' (ModuleNotFoundError: No module named 'spyder_kernels')
My remote VM uses Python 3.7.7 and is hosted by Google's cloud platform.
Any help much appreciated.

The issue is that running sudo pip install, you're using the root user's Python installation, and not the user installation you eventually run your command from.
Try using either python -m pip install spyder-kernels or sudo python -m spyder_kernels.console .... Preferably you would not run either command as root.

Related

Unable to Install Jupyter due to legacy-install-error with psutil package

I was previously running into environment inconsistencies after downloading tensorflow with pip in a conda environment, and after several hours of frustration, decided deleting anaconda/miniconda and python and starting from scratch would be my best option to get python working again (The inconsistencies were causing a plethora of issues with loading other modules like numpy, etc).
After downloading Python version 3.9.10 directly from https://www.python.org/downloads/macos/, I wanted to see if I could start using Python again in a Jupyter notebook in VS Code. When I try to run a simple print('hello world') in a python chunk I (unsurprisingly) get the following error:
Jupyter cannot be started. Error attempting to locate jupyter: Running cells with 'Python 3.9.10 64-bit' requires notebook package.
Run the following command to install 'jupyter and notebook' into the Python environment.
Command: 'python -m pip install jupyter notebook -U'
I was pretty much expecting this error, since I knew I had deleted all packages when deleting Anaconda and Python.
However, when I try running python -m pip install jupyter notebook -U in the terminal I ultimately get the following error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> psutil
note: This is an issue with the package mentioned above, not pip.
Any help or insight is greatly appreciated! I am on MacOS (M1) if that is useful information.
The problem seems to be with the python3 distribution that comes with MacOSX Command Line Tools. Well, at least that same error was gone after following these steps.
So, to fix the problem I installed python3.9 (I presume you can change 3.9 to your desired version, e.g. 3.8 or 3.10) using Homebrew.
Install Homebrew (to check if it's installed already just type brew --version in the terminal):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install python3.9
brew install python#3.9
Create your virtual environment
python3.9 -m venv myvenv
Activate the virtual environment with source myvenv/bin/activate
Finally, install Jupyter using
(myvenv) pip install jupyter notebook
I have the same problem when installing the Jupyter notebook on MacOS 12.5 M2 chip. It turns out that the error is caused by not having GCC on my mac to run the wheel for installing the psutil package because for some reason I removed my XCode from my Mac. So I installed XCode from AppStore and opened XCode after the installation to agree to its terms and conditions. After Xcode went through the setup process I tried pip install jupyter again and it worked well.
In my case, I just opened the XCode, accept the terms and the installation proposed, and tried to install the jupyter again and it worked!
It seems to be very particular about the version of python installed. I set up a fresh installation on a new box this morning and put 3.11 on there. pip install jupyterlabs gave me the same error as you got. I then uninstalled python and installed an earlier version, and now it works.
PS the older version that worked for me is 3.10.8

Cannot install python3.6 on Debian 4.9 VM

I'm running a Debian VM (4.9.189-3+deb9u1) on the Google cloud. I want to run a script on this instance; the script works fine on my local machine (Mac OSX Mojave 10.14.6; python 3.6.8). However, when I run it on the VM I get an error that seems to relate to the fact that my the VM runs python 3.4 when the script needs python 3.6+.
Here's the problem. When I run python -V, the response is Python 3.7.4. However, when I try to install the library supporting the script I want to run
pip3 install --user --upgrade -e
git+https://github.com/twintproject/twint.git#origin/master#egg=twint
I get
twint requires Python '>=3.6.0' but the running Python is 3.5.3.
I have tried changing the default python as detailed here; this doesn't seem to work––in fact, python 3.6 isn't even visible as an option when I query ls /usr/bin/python*. Can anyone offer some advice on how to proceed here? Thanks.
It seems like you have multiple Python versions available. If python -V gives you Python 3.7.4, you can use:
$ python -m pip install --user --upgrade -e git+https://github.com/twintproject/twint.git#origin/master#egg=twint
to invoke pip from that same Python interpreter.

How can I execute Ansible module of python on windows?

I installed Ansible on windows server 2012 via python 3.7
(follow by instructions of this post: https://stackoverflow.com/a/52614973/7098543).
But, I got error: No module named ansible.main. How can I solve it?
I know that Ansible does not support to install control machine on Windows. But, I have to use Windows server 2012.
After I installed Ansible (version: 2.7.10) via python 3.7, I try to run:
python -m ansible --version
I got error:
No module named ansible.main; 'ansible' is a package and cannot be directly executed.
Any workaround? Please help.
Actually, I have no idea or workaround to solve this issues. But, I found other solution to install Ansible with Cygwin.
1. Open up a Cygwin Terminal
2. alias cyg-get="/path/to/cygwin/setup/package/setup-x86_64.exe -q -P"
3. cyg-get cygwin32-gcc-g++,gcc-core,gcc-g++,git,libffi-devel,nano,openssl,openssl-devel,python-crypto,python3,python3-devel,python3-openssl,python3-pip,python3-setuptools,python3-devel,tree,wget,zip,make,curl,git python-jinja2,python-six,python-yaml, cryptography
4. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
5. python3 get-pip.py
6. pip --version
7. git clone --depth 1 git://github.com/ansible/ansible
8. cd ansible
9. python3 setup.py install
Hope this post help someone!
Refrence link:
Cygwin - How to install ansible?
How to overcome - pip install ansible on windows failing with filename or extension too long on windows

Unable to install python packages - Could not found suitable TLS certificate bundle

I am struggling to make Python (Anaconda) work from last few days. I had tried installing pytorch few days back and it crashed in between. Hence forth, my Anaconda is giving errors while installing any packages. I have Windows 10, 64 bit user with Python 3.6.1. - Intel chipset.
I am unable to install any package - above is the issue.
I even tried uninstalling and installing Anaconda which is the only Python distribution I have on my machine.
Another error which I receive -
Any help in this matter would be of great great help!!
Upgrade pip as follows:
curl https://bootstrap.pypa.io/get-pip.py | python
Note: You may need to use sudo python above if not in a virtual environment.
(Note that upgrading pip using pip i.e pip install --upgrade pip will also not upgrade it correctly. pip won't work unless using TLS >= 1.2.)
For PyCharm (virtualenv) users:
Run virtual environment with shell. (replace "./venv/bin/activate" to your own path)
source ./venv/bin/activate
Run upgrade
curl https://bootstrap.pypa.io/get-pip.py | python
Restart your PyCharm instance, and check your Python interpreter in Preference.

Python 3.5.2 Windows x86-64 web-based, but installer not installing pip

I am trying to install TensorFlow. The installation instruction for Windows (https://www.tensorflow.org/install/install_windows) have as first step to install Python 3.5.2. And I'm doing the 'TensorFlow with CPU support only'.
Python was successfully installed in my computer as I can run it via the Start menu.
However, when I try to do the 2nd step of the installation instructions in order to install TensorFlow, this step says to:
To install TensorFlow, start a terminal. Then issue the appropriate pip3 install command in that terminal. To install the CPU-only version of TensorFlow, enter the following command:
C:\> pip3 install --upgrade tensorflow
But I'm getting an error when I perform the above statement, the error is
'pip' is not recognized as an internal or external command, oprable program or batch file.
I looked at several postings in StackOverflow and tried the commands provided in one of the postings, but I would get the same type of error.
So, how is 'pip3' installed? from what I read, it is supposed to be installed together with the installation, but obviously that did not happen.
How do I install it? I need to install TensorFlow and it seems that it needs to be done via the pip3 installation tool.
Thank you in advance for your help!
Either set the system environment path variable to include the python 3.5.x path in it, or just cd into the correct python folder to run pip3 from there.
The folder in windows 10 should be something like this:
C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python35\Scripts
Open the terminal, cd to that path (change YOUR_USERNAME to the correct user) and then just run the following command:
pip3 install --upgrade tensorflow
and if you want the gpu version:
pip3 install --upgrade tensorflow-gpu
Pip3 is already installed when you install Python, so there is no need to do anything else.

Resources