pip looking in wrong folder - python

My issue requires some backstory.
I was having some troubles with pip, so I reinstalled Python. After the reinstall pip began to work, but Pycharm, my IDE, could no longer find Python. When I reinstalled Python it created a new folder for itself (Python310), but Pycharm kept looking in the old folder (Python39). I couldn't figure out how to get Pycharm to look in the new folder. Even deleting and reinstalling it did nothing.
So, I renamed Python310 to Python39 and changed the PATH. Now Pycharm can find Python. But pip has developed a new and exciting error. When I try to use it I get the following message:
Fatal error in launcher: Unable to create process using '"C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe" "C:\Users\user\AppData\Local\Programs\Python\Python39\Scripts\pip.exe" install numpy': The system cannot find the file specified.
If I read this correctly pip is still trying to look in Python310. Would you please tell me what I need to do to get pip to looking in the right place?

So, to start. You don't fix this by renaming the folder where the interpreter resides. Even if that worked, it's not a fix. The name will say one thing, but it's actual version, compatible libraries, and anything else tied to the version number would be incorrect.
If you take a close look at the error message from pip, it tells us what's wrong.
Fatal error in launcher: Unable to create process using '"C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe" "C:\Users\user\AppData\Local\Programs\Python\Python39\Scripts\pip.exe" install numpy': The system cannot find the file specified.
You renamed the directory, so your IDE can find it, but pip and everything else using the Python interpreter is still configured to look in the Python39 directory to find it.
The problem you are having is that your IDE, PyCharm, needs to be configured for your project. You have to tell it where the Python interpreter is. The simple solution, you can rename your your Python folder back to it's original state, and add it to your project.
Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.
Expand the list of the available interpreters and click the Show All link.
Select the target interpreter.
In your case, look for the one with this file path: "C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe"
I would recommend going one step futher and create an interpreter in a virtual environment. Especially if you are interested in Python beyond a very casual hobby. They are unavoidable.
This link is a good source and can help you with this:
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#interpreter
There, you will find screenshots that follow the steps I listed above. There are also detailed instructions on how to create and add a new interpreter in a virtual environment. The relevant headings are as follows:
Configure a Python interpreter
Python interpreters in PyCharm
Setting an existing Python interpreter
Creating a new Python interpreter
The rest of the content is great as well, and may help answer questions you didn't know you had.

try to uninstall all of the existing python versions. and install it again. using any of application allow you to delete most of files, so to prevent error when re-install .

Option 1:
delete and reinstall again. and then when creating a project it should prompt you to pick a basic interpreter, choose python310 or whatever version you're using.
Option 2:
use a different IDE.

Related

Python not found

I'm working on a project in a python virtual environment, the project was started on a pc with python 3.8 installed and consequently python 3.8 was used in the virtual environment, or I had the need to continue the project on another pc, so I loaded all on GitHub, in the end I downloaded it to another PC with python 3.11 installed, the files are all there but when I try, inside the virtual environment, to open python by writing python or python3 in the terminal, it shows up this error: Python not found; Run with no arguments to install from the Microsoft Store or disable the link from Settings > Manage apps Run aliases. I then tried to see if it only showed up inside the virtual environment, but the same thing happens outside as well.
I tried to do various things among those suggested in other forums but they didn't work, the problem persists, I'm a bit lost, it's the first time this has happened to me.
Sorry to bother, maybe it's the simplest problem there is to solve but I don't know where to start
Trhanks
The problem is the different version of python on the two computers... the content of the pyvenv.cfg file must simply be changed which, when creating the virtual environment, is based on the installed version. Here you just need to change the path to reach the python.exe file installed on your computer and then change its version by inserting the correct one.

Python inside a virtualenv is broken (Django)

TL;DR - Microsoft Store Apps are broken (0 bytes), hence the Python interpreter is unable to create process and run "Python" inside virtualenv, I failed to follow numerous explanations of how to change virtualenv path for Python.
Recently, without any changes to my computer/environment, an issue started occurring when executing (also tried python3, which brings the same):
python manage.py runserver
This brought back the following issue:
Unable to create process using
'"C:\Users\MyUser\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe"'
As I dug deeper, I realized that all of the apps installed under this folder are 0 bytes, hence they are completed broken, all of a sudden.
Therefore I figured it's not an issue with Django, rather the python itself.
I tried changing the virtualenv path for Python.exe, instead of using WindowsApps version, I installed the original Python from the original website.
I failed to do so, multiple times.
I tried: "https://stackoverflow.com/questions/4757178/how-do-you-set-your-pythonpath-in-an-already-created-virtualenv/47184788#47184788" - Adding the path inside "activate" and "activate.bat", as
set PYTHONPATH="C:\Users\MyUser\AppData\Local\Programs\Python\Python310\python.exe"
And the issue persists.
I tried every solution/article I found in regards to the issue I have. Many of them claim a simple result, whereas the rest claim a complete refactor is required.
Even downloading from Microsoft store is broken, it always fails.
Since I'm unable to remove the broken apps, and I wasn't able to find a way to change the virtualenv Python interpreter, I am here, asking for your assistance.
Thanks in advance,
Since you have installed python from python.org, ensure that it has been properly added to the PATH and you're not inadvertently using the windows store version.
Open command prompt
Execute where python to check which python your system is using.
If you're only seeing the WindowsApps version of python listed in the output of where command, then python installer apparently didn't add the location to PATH, so you'll need to manually add it yourself.
Also, if you're not restricted to use virtualenv, you can give conda a try.
As I began rebuilding, I figured it out.
When building a virtualenv, the python I used was directing to:
"C:\Users\MyUser\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe"'
Python interpreter is saved as the "PATH" to execute python.
Since my Python interpreter from Microsoft Store went broke, I was unable to execute python inside the virtual environment.
Venv configures a file called:
pyvenv.cfg
This is how the virtual environment knows what Python interpreter to use.
Inside it, the first line states:
home = C:\Users\MyUser\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\
Therefore, we just need to re-configure it to the new path of Python interpreter:
home = C:\Users\MyUser\AppData\Local\Programs\Python\Python310
And it worked for me.
Thanks for everyone's assistant, glad it's done.

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings

I was trying to download a GUI, but the terminal kept giving me this error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
I'm trying to install it using this command:
python -m pip install --upgrade pip setuptools virtualenv
Check your Python version and be sure it is installed on your machine
Check the path environment variable
Go to -> "start" and type "Manage App Execution Aliases". Go to it and turn off "Python"
I was having the same issue and I fixed it by using the below method.
Copy two paths of Python
C:\Users\Maninder\AppData\Local\Programs\Python\Python39
C:\Users\Maninder\AppData\Local\Programs\Python\Python39\Scripts
These are the paths where your Python interpreter is installed. Now add this path into your environmental
variable. Put this path into System variable, not in user variable. I was using user variable, so I was facing the issue.
I have a solution for you. Make sure you check the path mark during installation. Then you need to go to Manage App Execution Aliases.
Simply go to your search bar and search for Manage App Execution Aliases. You will find the attached screen and you need to turn off App Installers as you see on the screen. Also, see the path,,, follow Maninder's answer.
Then you are good to go! :)
I had the same issue. In Windows CMD, only: py --version, works.
I tried adding the path on System variables, and it didn't work. If you are using PyCharm as I do, try to run all commands from the IDE's terminal. It usually is on the side bar where the Run and the Console is. If it is not, go to: menu View → Tool Windows → Terminal. It worked just fine for me.
You need to download Python from https://python.org. When in the installation, be sure to check the option that adds Python to PATH.
I haven't gotten this error before and have been using Python a long time, and then suddenly it showed up. I think that it is a result of a Windows update designed to steer you to their store.
In any case: to remedy the problem, go to Settings → app execution aliases → and turn "off" Python. (What they tell you to do, in other words). This should resolve the problem.
If you have installed Python successfully with add python path, ticked on, and have added
C:\Users\<user>\AppData\Local\Programs\Python\Python39
C:\Users\<user>\AppData\Local\Programs\Python\Python39\Scripts
to the path into System variables and have turned off the "aliases" and they all didn't work, you can simply use python instead of python3 in your cmd command.
Check the Aliases for App Execution in Windows. Search for Alias App in your Windows toolbar to find the UI for this. Try turning off anything Python related.
Try adding the following to your "Path" environment variable:
C:\Users\Default\AppData\Local\Programs\Python\Python37
C:\Users\Default\AppData\Local\Programs\Python\Python37\Scripts
Replace Python37 with your own version.
I solved this problem for Visual Studio Code with just writing "python" in the console:
python
After that, Microsoft Store opens automatically with the Python app:
And I just click Get.
And it all work!
All the previous answers are correct, but in my case, I was getting this, because I was not passing the version...
The fix is passing the version:
py.exe -3 your_program
If you're on Windows, you may want to use the Python installer, in Windows Marketplace.
I faced the same error while using Anaconda and trying to link the Python executable path in the command prompt.
It got rectified by going to Settings → App execution aliases → and turning "off" Python. Then again I had to set the path for Python in Anaconda and was successful in executing "python --version" command.
The same thing happened to me even after trying all the above-mentioned steps.
I just restart my system and it was working fine. Do it and if still doesn't fix the issue then make sure you have checked "add python ( any version ) to PATH" before installing Python.
If none of the previous answers are working, you can check if you have the Python executable in your program files.
Go to C:\Program Files and check if you have the Python application. If not, go to the python download website here and download the .exe file.
While installing you must select "Custom install" and select the location as C:/Program Files.
Install it and it should work now from anywhere. This worked for me!
To sincerely resolve this issue, do the following:
Uninstall the Python instance and reinstall it. Note: Make sure you check
"Add variable PATH".
On the command line, type:
python -m pip install --upgrade pip setuptools virtualenv
I got this issue when I used Visual Studio Code as the IDE, and Anaconda as my Python compiler. And you don't need to close the "app alias" in settings, but copy your python.exe to python3.exe in your Anaconda folder.
That happened to me. So, to fix it, you have to follow the following steps:
Uninstall the Python version you already installed.
Go ahead and open the installation file to reinstall it again.
Before hitting Install Now, make sure to tick the box in front of Add Python to path.
Go ahead and complete the installation procedure as usual.
Steps for installing Python
The problem is more subtle than it seems.
For example, if you are using Visual Studio Code on the bottom left, you should see Python X.X.X xx-bit (the X is the version).
If you click in there you will see where the IDE is getting the python.exe from.
Locate that folder into your file explorer and then just follow the answer that is saying to change the environments variables.
So copy the path where python.exe is and add it to the Path variable and do the same where the Script folder is (it is in the same directory where the python.exe is).
Then of course make sure your IDE is using the right Python.
None of the answers here worked for me. I did this and the error went away.
For Windows 11 which I was using, I reran the python-3.10.5-amd64.exe file from my downloads directory and then chose to modify the installation.
Then I followed these easy steps.
Make sure the PIP component is checked before proceeding to install.
Then check 'Add Python to environment variables' if it's not checked already.
Proceed to Install.
At this point, your error will be solved
If you already have the Python executable on your machine and you are getting this error in Windows 10, search for the Python executable and copy its path then copy the path in system variables. It worked for me.
to check in windows
py --version
or restart your pc first then put htis command again
I was also facing this issue after installing python, while running command
python --version in command prompt , error as:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
So, i too added
the path in environment variable as shown, and it worked:

Why is python setup popping up when I start Pycharm and where is my python interpreter?

When I start Pycharm, this python setup menu pops up.
Python 3.7.4 is not even the version I'm using. Everything else works fine and I can just close it, but it is annoying.
There was a same question, and the answer was
You appear to be using the installer .exe as if it were the Python interpreter. Install Python to somewhere first, then use the python.exe in the bin directory inside that.
But I can't find where my bin directory is. My Python37-32 folder looks this.
How do I find my python interpreter?
Open some project -> File -> Settings -> Project: ... -> Project Interpreter -> Show All ... to view the list of available interpreters added to PyCharm.
Find and remove the interpreter which is pointing to Python distributive from the newly opened list.
At some point in past you added Python installer as a project interpreter in PyCharm so now when IDE tries to use this exe to run some background tasks (e.g. to get sys.path) installation wizard is triggered instead.
Correct python.exe to point PyCharm to is right on your screenshot
According to official python documentation.
The Python interpreter is usually installed as
/usr/local/bin/python3.8 on those machines where it is available;
putting /usr/local/bin in your Unix shell’s search path makes it
possible to start it by typing the command:
Since you are using Windows here, you are already in the location where the python interpreter resides. So look no further.
By the looks of the screenshots, I have a concern whether you have installed python correctly.
If you did not select the checkbox for Add Python 3.7 to PATH, the wizard expects you to do it manually which is why the error.
I would uninstall and reinstall Python and this time make sure to check that box. I am sure your error messages should go away.
Alternatively, if you're not in the disposition to uninstall. According to python docs here you can set the python variable to PATH variable and try.

PyCharm always thows this error on creating new project and interpreter(virtual env) is missing for the project

I have got a problem with pycharm. I reinstalled everything(system python, anaconda, pycharm) since I thought it was conflicting with Anaconda. Finally, I completely got rid of Anaconda and still Pycharm throws the following error whenever I create a new project.
Unable to create process using 'C:\Users\Ritanshu Singh\AppData\Local\Programs\Python\Python37\python.exe
"C:\Program Files\JetBrains\PyCharm Community Edition
2018.3.2\helpers\packaging_tool.py" list'
Also the project(virtual env) interpreter is missing every time I create a new project(My actual system python is installed and works well, I have tried and run a raw python text file) and I can't run the python code. I googled but it shows no results.
I figured out that it has a problem to create virtual environment interpreter but I don't know why? The error code is above listed.
There is a very good documentation available for configuring the python interpreter in Pycharm: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html and
https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
Please verify that you follow these steps before starting the Pycharm.
Do not import config.
Check the user permission which starts the Pycharm(Administrative).
Add path variable for python in windows.
install and configure the pip that will help you to download the package while setting up the interpreter.
I found that from Python version 3.3+, the built-in venv module is used, instead of the third-party virtualenv utility. It is written on PyCharm Official Page on this link: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html

Categories