Does Spyder download its own Python with it? - python

Common issue here: I installed Python and then Spyder, and now when I install packages with "pip install ", Spyder can't find the modules, but if I call Python on the command prompt (using Windows), it finds all installed packages with pip.
I noticed that in Spyder, a new console shows it is running Python 3.7.9, but if I run "python -V" on the command promp, it shows Python 3.9.1 , also for "py -0" and "py -0p" it only shows one installation of Python, namely
>>> py -0p
Installed Pythons found by py Launcher for Windows
-3.9-64 C:\Users\my_name\AppData\Local\Programs\Python\Python39\python.exe *
so what is going on here? Why does Spyder seem to have its own Python version? Is this the reason why packages installed with pip are not communicating with Spyder?

I was facing the same issue as you. I understand your question and the answer to it is yes. However you can change it and use the systems python as well.
Tools -> preferences -> python interpreter -> select "use the following interpreter" and provide is the path to the directory that you have the systems python installed.
Restart spyder and the kernel should then show you the update version

For any library that you want to add that is not included in the default search path of spyder, you need add its path via the PYTHONPATH manager.
Go to Spyder->Tool-> PYTHONPATH manager ->Add Path

Related

Why isn't autocompleteworking in vscode for python external packages?

I am new to python and I guess pyCharm is the most preferred IDE for python but I want to stick to vscode if possible. I have the python extension installed in vscode and autocomplete works fine for default python packages but for external packages like pillow or PyPDF2, its not working.
I created a virtual environment where I installed the above 2 packages using pip and even checked if the packages are installed using pip freeze.
Pip freeze is showing:
Pillow==9.0.1
PyPDF2==1.26.0
Below is my project structure. I need to import PyPDF2 module from basic.py. Also, if it helps, I am using python 3.9.6. Any help or suggestions are greatly appreciated.
You need to select the interpreter by following the docs.
Through the python extension, you can set the interpreter so that the packages will be taken from the environment. The interpreter is basically the python that your virtual env uses so it has access to the python packages that you installed in the virtual env.
Here are the steps in case the docs change:
CTRL+Shift+P or Command+Shift+P depending on if you're on Windows or Mac respectively
Type Python: Select Interpreter after the >
Then you can either select the interpreter from your virtual env that you created or enter the path to the interpreter.
Did you select the interpreter inside the vscode?
Enter vscode and type
ctrl+shift+p
and type in command prompt
>python:Select Interpreter
and then activate the Interpreter.
This will do the trick for you.

Spyder doesnt recognize any installed packages, so doesnt load them

I have been dealing with this problem for months and still found no solution.
I installed anacond first, and then installed spyder (but not from anaconda interface, but from outside it). I want to use spyder but when I open cmd terminal and type "pip install pyarrow", the cmd shows it is already installed but spyder doesnt load it.
Thank you very much/
Maybe Spyder is running a python interpreter version (say 3.7), but the pyarrow package was only installed for a later version (say 3.8).
Try this:
Check your Python interpreter version
Check for which versions of Python was Pyarrow package installed.
Spyder runs a python interpreter by default and you can change which version to run:
Go to Spyder --> Preferences --> Python interpreter --> Use the following python interpreter (insert the path of the desired python version).

PIP version VSCode

I am having troubles trying to understand why VSCode uses a different pip version.
I have two python versions installed in Windows, python38 and python39, if I open the win 10 terminal I got pip version 20.2.4 when running pip3 --version, but if i run the same command inside the VSCode terminal i got pip 20.2.2 from c:\python38\lib\site-packages\pip (python 3.8).
Both terminals are running PowerShell 7.0.3 on the same profile.
Also removing python38 from the global PATH variable gives command not found error only in vscode, in windows terminal keeps working as i described before.
Could not fix this so I deleted all temporary and profile data of vscode and can now run pip from within its terminal.
Try changing your interpreter: ctrl+shift+p->select python interpreter and choose the one you want because pip is part of the python environment, and therefore the version of pip you are using is tied to the active python interpreter (cc #DragonBobZ)
It's all about the Process PATH. Check $Env:PATH in both. Starting from the left, the first folder with pip3.exe is used. You have probably selected a python interpreter for VS Code, which then adds it in the PATH.
You can also check the location of the used pip3.exe with Get-Command pip3. (might be helpful in debugging)
It appears something got fixed after deleting all profile and settings data from visual studio code, it runs pip now form the terminal inside vscode.

Module not found in pycharm (Windows)

I wanted to install Pytorch via anaconda and it worked but PyCharm can't find the module (
ModuleNotFoundError: No module named 'torch'
I also have CUDA installed but when I looked up to add a the package with pycharm it also gives an error. When I added the anaconda interpreter I can't run the code. I use Python 3.6
Ok I solved this problem: First install anaconda and open the prompt then type conda install pytorch -c pytorch and pip3 install torchvision. Then go to PyCharm and create an Project and set the Project Interpreter to the Anaconda one (there is in the path: \Anaconda.x.x\python.exe ). Then you go to the Run settings and click Run... and then you go to Edit Configurations and then you select the Project Default interpreter and apply and you should be done! Thanks to the ppl who helped me =)
In you are on ubuntu and have installed pytorch using anaconda then in the interpreter of the pycharm which is under
File -> Settings -> Interpreter you have to do following:
search for the conda where it is installed by doing where conda then in that you will find a python.exe in your environment folder provide the path of that in the python interpreter.
Try with this it should work as I was facing the similar issue on windows solved it using this procedure.
And probably where conda won't work if you don't have support for ubuntu commands in windows than you can go to the folder where Anaconda is there which probably will be in your Users -> 'Your User' folder in that search for you environment and in that go to your environment and find python.exe give this path in pycharm.

can't install pygame using pip, Python 2.7.6 on Win7

I've installed Python 2.7.6 (32-bit) on Windows 7 (64-bit). This works fine in Windows Power Shell. I set the PATH to C:\Users\name\Python27\Scripts, and that didn't seem to be a problem either. I then downloaded a pygame install file, pygame-1.9.2a0-cp27-none-win32.whl, from:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
I put the .whl file into the Python27\Scripts directory, and tried using pip install pygame-1.9.2a0-cp27-none-win32.whl in Windows Power Shell (command line, not Python interpreter), and the error message is this:
The term 'pip' is not recognized as the name of cmdlet, function, script file, or operable program.
I tried using Python 2.7.8 (the later version of Python 2.7, if I'm not wrong) with an .msi install of pygame, but I experienced other errors with this that I thought could be fixed with a fresh install. I am very new to programming and using the command line; any help is appreciated.
you must not have set the path variable in windows..it's the same mistake that i made..
set the environment variable in windows by doing fallowing steps:
right click 'My Computer'
go to properties
Advanced System Settings
Environment Variables
and set Path there..
if this doesn't help then try another method :
open your python installation directory
goto Tools
Scripts
Run "win_add2path.py"
Now try to run $) pip install, commd..
if it still doesn't work .. restart your console or restart the PC
#shub1493biswas#gmail.com

Categories

Resources