Install spyder independently(without Anaconda, python x,y) on windows 10 - python-3.x

I was trying to install spyder on windows 10 with the python version 3.6+. But it was not working. It was giving me the following error. Seriously, i don't know what these error means. Error:
An error ocurred while starting the kernel
Traceback (most recent call last):
File "c:\python36\lib\site packages\spyder\utils\ipython\start_kernel.py", line 269, in
main()
File "c:\python36\lib\site packages\spyder\utils\ipython\start_kernel.py", line 237, in main
from ipykernel.kernelapp import IPKernelApp
File "c:\python36\lib\site packages\ipykernel\__init__.py", line 2, in
from .connect import *
File "c:\python36\lib\site packages\ipykernel\connect.py", line 13, in
from IPython.core.profiledir import ProfileDir
File "c:\python36\lib\site packages\IPython\__init__.py", line 41, in
""")
ImportError:
IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Beginning with IPython 6.0, Python 3.3 and above is required.
See IPython `README.rst` file for more information:
https://github.com/ipython/ipython/blob/master/README.rst

I just deleted all the previous version of the python from the C drive manually.
then, install the python 3.6.5(latest stable version available) at the time of posting.
Sometimes i faced issues in installing python and access it through windows cmd.
To resolve this, during the installation of python 3.6.5, opt for customized installation and when it ask for the folder in which to install it.
just create a folder in C drive with name Python36 and install python in this folder. Means install python in C:\Python36
and add two paths to the Path variable using the following commands.
setx path "%path%;C:\Python36;"
setx path "%path%;C:\Python36\Scripts;"
and then, try python.
To check, just type python --version
if it is working, python is ready to use
Then, i tried to install SIP package from pip. but pip was not working.
then, i manually install and upgrade the pip on my system using the following commands windows command line,
python -m pip install pip==9.0.0 # will install pip
pip install -U pip # will upgrade pip
pip got installed successfully and the version i checked was
pip 9.0.3 using the following command on windows command line:
pip --version
After that just run the following commands from cmd:
pip3 install SIP
pip3 install PyQt5
pip install spyder
Then, to check either spyder is working or not, just go the directory in which python is installed. e.g. on my sysytem, directory is C:\Python36\Scripts. search for spyder3app and click on it. and create a shortcut for it.
Versions:
PyQt5 (5.9.2)
sip (4.19.8)

Install the spyder using pip:
pip install spyder

Related

Unexpected version discrepancy with VSCode, pip, venv and terminal

I'm using the current version of VSCode on Ubuntu 22.04.1, Python 3.11.1 and venv. I installed many packages and never seen this problem before. In this environment:
I installed a package with pip install clipspy, which completed successfully and pip lists the package as clipspy 1.0.0. Running a test script inside VSCode produces:
(.venv) paul#desktop:~/work/arc/code$ cd /home/paul/work/arc/code ; /usr/bin/env /home/paul/work/arc/code/.venv/bin/python /home/paul/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 36033 -- /home/paul/work/arc/code/clips-0.py
Traceback (most recent call last):
File "/home/paul/work/arc/code/clips-0.py", line 1, in <module>
import clips
ModuleNotFoundError: No module named 'clips'
(.venv) paul#desktop:~/work/arc/code$ python3 --version
Python 3.11.1
Strangely, when I open a terminal and activate the same virtual environment with Python 3.10.6
(.venv) paul#desktop:~/work/arc/code$ python3 clips-0.py
Hello John Doe
(.venv) paul#desktop:~/work/arc/code$ python3 --version
Python 3.10.6
It runs fine. It fails with Python 3.11.1, though. Can someone explain what is happening here? How can I make this module run with Python 3.11?
I created a new VSCode project and venv, repeated the installation and it works as expected now. The previous project had well over 100 modules installed. Is it likely that venv environment got corrupted somehow?

Numpy cannot be imported even though it is installed

I am using Linux Mint 19.3 XFCE.
I have installed Numpy through pip3. pip3 was not installed already, and I installed pip3 thorugh apt.
The default version of python3 that came with the OS is 3.6.9. Since I am not supposed to change the default version of Python that comes installed with the OS, I kept that. And I installed a newer version, 3.8.0 with snap.
The command was-
sudo snap install python38
And now, whenever I need to work with the interpreter, I just type python38 into the terminal and get on with it.
I recently installed Numpy with pip3-
pip3 install numpy
and it shows up when I run pip3 freeze
:
It is listed as-
numpy==1.18.1
But when I enter the Python interpreter through typing python38 into my terminal, and type in import numpy, I am shown an error:
import numpy as np
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'numpy'
However, when I try the same with Python 3.6.9, it works. Numpy is improted, works just fine. (This time I enter Python interpreter by typing python3)
Now, how do I permanently solve this? That is, being able to import Numpy when working in Python 3.8 in terminal.
This may be the reason because your pip is configured for the default version of python in the machine(Python 3.6.9 in your case). You may change your default python version.
Or
You could run pip and install your python package for specific python version like
python_version -m pip install your_package
eg
python38 -m pip install numpy

Python/Tkinter : ModuleNotFoundError: No module named '_tkinter'

This is my first post StackOverflow, I will try to make it as correct and complete as possible if you have any tips to improve my post I will gladly accept it.
I'm having trouble running code written in Python that uses Tkinter.
I will try to describe in detail my actions to facilitate the identification of the error.
I started a course at Coursera on DSP (Digital Signal Processing) where it is suggested to install a tool written in python (and a little bit of C). I'm using Arch Linux.
link on Github:
sms-tools repo
Using pyenv/virtualenv/virtualenvwrapper I created an environment with Python 3.7.5, as recommended in the "How to use" section of the repository.
I installed the required libraries in my environment by pip:
%pip install ipython numpy matplotlib scipy cython
I compiled some C functions in the "/sms-tools/software/models/utilFunctions_C"
directory with the following command:
%python compileModule.py build_ext --inplace
Finally, I run the models GUI in the directory "/sms-tools/software/models_interface"
%python models_GUI.py
and I get the following message:
Traceback (most recent call last):
File "models_GUI.py", line 6, in <module>
from Tkinter import * ## notice capitalized T in Tkinter
ModuleNotFoundError: No module named 'Tkinter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "models_GUI.py", line 9, in <module>
from tkinter import * ## notice lowercase 't' in tkinter here
File "~/.pyenv/versions/3.7.5/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I will now describe some of my attempts to solve the problem:
Looking at Tkinter section in Python Wiki I tried installing Tcl and Tk.
%sudo pacman -S tk
but it was already installed. after that I tried installing with pip:
%pip install tk
and
%pip install tkinter
and the error remains the same.
I also tried to create a symlink with this code:
%ln -s /usr/lib/python3.8/lib-dynload/_tkinter.cpython-38-x86_64-linux-gnu.so _tkinter.cpython-38-x86_64-linux-gnu.so
the symlink was created in the following folders:
~/.ve/Coursera_DSP/lib/python3.7/lib-dynload
and
.pyenv/versions/3.7.5/lib/python3.7/lib-dynload
But I still get the same error.
I appreciate it if anyone has any suggestions and I apologize for the language errors since English is not my mother tongue.
After an incessant search on the internet, I believe the problem is related to pyenv and TCL/TK.
I don't understand much about the subject but I suspect that in the creation of the environment by virtualenv python has lost the connection with TCL/TK. Does that make any sense?
Here is step by step guide to make IDLE and tkinter work. Working for me on macOS Catalina. Should be easily adapted to Linux environment:
install tcl-tk with Homebrew. In shell run brew install tcl-tk
in shell run echo 'export PATH="/usr/local/opt/tcl-tk/bin:$PATH"' >> ~/.zshrc
reload shell by quitting Terminal app or run source ~/.zshrc
after reloaded check that tck-tk is in $PATH. Run echo $PATH | grep --color=auto tcl-tk. As the result you should see your $PATH contents with tcl-tk highlighted
now we run three commands from Homebrew's output from step #1
in shell run export LDFLAGS="-L/usr/local/opt/tcl-tk/lib"
in shell run export CPPFLAGS="-I/usr/local/opt/tcl-tk/include"
in shell run export PKG_CONFIG_PATH="/usr/local/opt/tcl-tk/lib/pkgconfig"
if you have your Python version already installed with pyenv then uninstall it with pyenv uninstall <your python version>. E.g. pyenv uninstall 3.8.2
set environment variable that will be used by python-build. In shell run PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'"
Note: in future use tck-tk version that actually installed with Homebrew. At the moment of posting 8.6 was the actual
finally install Python with pyenv with pyenv install <version>. E.g. pyenv install 3.8.2
Test
in shell run pyenv global <verion that you've just installed>
now check IDLE. In shell run idle. You should see IDLE window without any warnings and "text printed in red".
now check tkinter. In shell run python -m tkinter -c "tkinter._test()". You should see test window like on the image:
That's it!
My environment:
check this is something went wrong executing steps above:
macOS Catalina
zsh (included in macOS Catalina) = "shell" above
Homebrew (installed with instructions from Homebrew official website)
pyenv (installed with Homebrew and PATH updated according to pyenv official readme from GitHub)
Python 3.8.x - 3.9.x (installed with pyenv install <version> command)
mac Monterey (M1)
brew install python-tk
python 3.9.10
My basic install of linux mint 20 contains python3.
On windows machines this includes the tkinter package.
My solution was to
sudo apt-get install python-tk
or
sudo apt-get install python3-tk
and live was sunny again.
I created a venv using Python 3.10.5 (alternate version to default 3.8). Tkinter failed to install when I used the command "sudo apt-get install python3-tk"; however, when I used "sudo apt-get install python3.10-tk", the module installed properly. Apparently, using the specific python3 version made the difference.
Since I couldn't find any solution I just uninstalled my whole environment system (pyenv pyenv-virtualenv virtualenv and virtualenvwrapper) and installed conda instead. Now everything works.
Probably I messed up with pyenv installation.
Thank you all :D

Python3 permissions and installing ipython/jupyter extensions

My question is two-fold, but I believe they are related:
I have recently realized that I have a permission issue with my python3 installation. If I run python3, I cannot import any packages. However, if I run sudo python3, all packages import flawlessly. Similarly, I must run jupyter notebooks with sudo as well. From reading, I believe I have made an error by installing many packages with sudo pip. Is there a straightforward way to fix this?
I am trying to install ipython extensions without luck. Using
sudo pip install https://github.com/ipython-contrib/IPython-notebook-extensions/archive/master.zip --user
I receive an error error: command 'x86_64-linux-gnu-gcc' failed with exit status 1.
If I download the zip file, and run sudo python3 setup.py install, the error is:
IPython-notebook-extensions/configure_nbextensions.py", line 80, in <module>
except (psutil.ZombieProcess, psutil.AccessDenied):
AttributeError: 'module' object has no attribute 'ZombieProcess'
If I run python setup.py install, the resulting error is:
File "/usr/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
This is the same error that I get when importing a package from python (when opened with python, rather than sudo python) in the terminal.
I am using Ubuntu 14.04.
except (psutil.ZombieProcess, psutil.AccessDenied):
AttributeError: 'module' object has no attribute 'ZombieProcess'
From the message,The old version of psutil is missing these module.
you should update the package of psutil use:
sudo pip3 install --upgrade psutil

pip3 works with python3.2 but won't work with python3.3

I have created a virtual environment for python3
virtualenv -p /usr/bin/python3 myenv
Everything works ok and pip installs python3 packages. Then I need to upgrade my python3.2 to python3.3. I am using ubuntu 12.04, so I need to do what Luper Rouch suggests here through ppa
I copy /usr/bin/python3.3 into myenv/bin/python3, thus (inside myenv):
python --version
returns Python 3.3.5. But then pip stops working failing with
pip install urllib3
Traceback (most recent call last):
File "mypathtoevn/bin/pip", line 7, in <module>
from pip import main
ImportError: No module named 'pip'
Then I understand that I have to use
pip3.3 install <package_name>
but I can't find any other pip*.* version either globally or inside virtualenv in my system.
How can I get pip3.3 or any other pip version?
Thanks
The ppa you have installed does not contain pip. The python package installer is itself installed with easy_install. On the question you linked to follow the later parts of this answer
Basically, calling
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
easy_install pip
should be sufficient. You should use the easy_install command of your Python3.3 install.
Check with
which python
where your python comes from, and search for easy_install in that path. In your case you know where it resides: Your virtualenv.

Resources