i am making a hard version of atari breakout
so when i import pymunk because I wanted to make the ball then it will say "no module named "_cffi_backend"
i have asked people on Youtube and reddit but nobody answered the questions
i have tried uninstalling cffi and pymunk, downgrading python and more
can anybody fix this problem
(and also i use microsoft visual studio 2019 and pyglet and python 3.9)
https://i.stack.imgur.com/sBY1O.png
Can it be because of something fishy with Visual Studio? Otherwise I cant think of much..
To validate if Pymunk can work on your computer you can try to install a fresh Python and Pymunk through conda, which will give you a completely separate installation of Python.
Download and install Miniforge: https://github.com/conda-forge/miniforge (If you get the option, dont set this new miniforge Python as your default Python)
Open the miniforge command line prompt and run conda install pymunk
When installed, run python -m pymunk.tests
Add the output here :)
Secondly, you can try to run your project from the command line instead of from within VS.
First you need to find out the folder where you have the files. In VS you can right-click on the file and use "Open Containing Folder" to go to the file in Explorer. You can also use "Copy full path" to copy the path.
Next, open the command prompt (or Windows Terminal in case you have it installed).
Navigate to the folder with the file. cd long-path-to-folder
Run the "main" file, I guess its atari.py in your case, but Im not really sure.
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:
I have recently started learning python using code academy and today I downloaded everything that I thought I would use. I downloaded Python and Atom. I have two separate drives on my computer. An SSD with not much storage and a hard drive with a lot of storage. My Windows is installed on the SSD, but I wanted to download python and atom on the hard drive, so I did so. When I installed Python I made sure to check add to PATH and the environmental variable thing. Now when I go to the command prompt, it shows "C:\Users\Gustavo>" but my python is installed on a different drive. Is there a way I could make this work? Thanks a lot.
There are two ways to install python:
Download directly from the website
Use a package manager
Case 1: Download directly from the website
Go to the python's website to download the version you would like to use.
Install the downloaded file (During the installation you can customize the installation directory)
Make sure to enable "Add python.exe to Path"
After installation has been completed, open your command prompt and type where python. Your python directory should be printed.
If all is good, then typing python should launch python in your command prompt. You can also run python by cd in the directory where your python is located and launch the .exe
You have mentioned about changing path and environmental variables, and that's probably for the purpose of keeping multiple versions of python. If that's the case, there's actually a quick fix for this:
Go to the folder where you installed Python.
Copy the python.exe file, and rename that copy in the same directory as python3.exe (If you installed version 2, then rename as python2.exe).
Now in command prompt type python2 or python3 and you should be able to launch either versions respectively.
Note: If you face issues regarding paths, then you should detail the error messages.
Case 2: Use a package manager
Choose a package manger: chocolatey, scoop, and others.
Check out these links for changing package manager's installation directory, installation method varies by the managers, so you should consult the developers should you experience problems:
chocolatey
scoop
Package managers will manage the versions for you, if you choose to install multiple versions. You should refer to the package manager's website for detailed information. However, you can quickly check the installed version by typing python --version. The python version number should be printed back to you, same applies to python3.
Double check your installation directory by which python
Type python or python3 to run your python of choice.
Lastly, you have mentioned atom. Atom is just a text editor: you can write python codes with it.
When you are done editing, you can open the command prompt and navigate to where your code resides, and type
python filename.py
This will run your code directly from the command prompt. There are many atom plugins available to make this process seamlessly integrated within atom. iPython and Jupyter plugins are first things that comes to my mind, you should specifically check out Hydrogen.
I made my second program in Python. It's a program that calculates the roots of a quadratic equation. I think it's cool and I want to let my friends use it without having to let them install python.
I heard about Pyinstaller from a friend and I tried this method out: first I typed pip install pyinstaller in cmd. Then I changed directory to the folder that contains the file that I want to share with my friends (it's called vkv.py). Then I entered this command: pyinstaller vkv.py but I got this error: Indexerror: tuple index out of range. Apparently the problem was that I have Python 3.6.0 and Pyinstaller only works with versions up to Python 3.5.
So I had to try another method. Yesterday, I tried cx_Freeze and some other method that I forgot, but both of them failed. Cx_Freeze failed due to me having Python 3.6.0 (same as Pyinstaller) and I don't remember what went wrong with the other method.
My friend (who told me about Pyinstaller) told me to use virtualenv, so I looked up a tutorial on the matter. Looks like I needed to make a virtual environment where I use Python 3.5. So these are the commands that I typed in cmd:
pip install virtualenv
mkdir Environments
cd environments
virtualenv -p C:\Users\hp\AppData\Local\Programs\Python\Python35\python.exe py35_env (before entering this command, I installed Python 3.5.0)
C:\Users\hp\Environments\py35_env\Scripts\activate
Now that the environment has been made and activated, I installed Pyinstaller in this environment, with pip install pyinstaller. Then I changed directory to: C:\Users\hp\Desktop\Code\Python testing (which is where the vkv.py file is located at). Then I typed: pyinstaller vkv.py, but now I got a whole bunch of lines, with an error on the last line: ImportError: DLL load failed: %1 is not a valid Win32 application.. Here is a screenshot of it:
Being the curious person that I am, I wanted to know what would happen if I opened another cmd window and tried Pyinstaller again without the environment (so I basically tried the very first method again, listed above). It is strange that I got the same "ImportError" and not the "IndexError" from before.
So now my questions are (ranked from more important to less important):
what can I do to let my friends run the Python file without having to install Python?
What does this ImportError mean and how can I fix it?
What happened there with the last time that I tried pyinstaller vkv.py in cmd outside of the environment? Why did it give me an ImportError and not the IndexError, which is what I got when I first tried to run this command?
Sorry to make this a long post, but I like to give a lot of information because I'm afraid that I might leave something important out.
Thanks in advance for any kind of help!
As you want to use Python 3.6, you can't use Pyinstaller, py2exe, cx_Freeze or others. However, there is a tool called Transcrypt and it's compatible with Python 3.6. It can be installed with pip: pip install transcrypt, and converts Python code into JavaScript. To use it open the console and type transcrypt vkv.py.
It automatically generates a folder, __javascript__, and files on it. When transcript ends, you are ready to use it with html.
(Assuming the .html is in the same directory as the .py and the folder)
<html>
<head>
<title>Example</title>
</head>
<body>
<script src="./__javascript__/vkv.min.js"></script>
</body>
</html>
You can use the html as an executable (depending on your program, here is the documentation) by running it with your browser.
Try removing 3.6 and installing 3.5.3 from python.org.
Retry with Pyinstaller.
Try using py2exe, it's a python module.
Its really simple all you need to do is:
Download and install it http://sourceforge.net/projects/py2exe/files/
Create your setup.py
Run your setup.py
Here's a site that will explain it more in detail http://inventwithpython.com/appendixc.html
I am able to use pyinstaller in my Python 3.6 environment. You need to download the zip file for Development Release (unstable) and instead of using pip, run the setup.py file from downloaded pyinstaller code.
I am using python 3.6 and nothing is working for me. I just can't install any of the tools for creating an executable. I tried cx_freeze, using pip had Visual C++ errors which I fixed and then it had more errors so I downloaded a wheel and that installed and in my Scripts folder there are three cxfreeze related files, none of which are batch files and when I run 'cxfreeze' in cmd it just says it is not recognised. For some reason python is installed in appdata/local/programs... but that is set in my path so I cannot see how that doesn't work. I tried pyinstaller with both pip and the download and nothing but errors about pypiwin32 which I can't get because of some other errors.
I do not know what is happening and I do not know what to do about all of this. Can someone just help me get a tool working to create an executable please. Is this because I am using python 3.6?
Try py2app (if you are on a mac) or py2exe (if you are on a windows). The setup is relatively easy.
https://pythonhosted.org/py2app/
http://www.py2exe.org/