I have a Raspberry Pi 4 running Raspbian 10. I've been trying to update the version of Python 3 that is installed so I can run Home Assistant which required 3.9.0, but it's all gone a bit pear shaped. The Pi runs a couple of other things so I'm doing a manual install instead of using the bundled Home Assistant OS.
I did have Python 3.7.3 installed. I then installed 3.9.0 apparently successfully. However running python3 --version
was still reporting 3.7.3. After a bit of Googling I managed to get the
python --version
command to show 3.9.0. But python3 stubbornly continues to report 3.7.3. How do I get
python3 --version
to report 3.9.0 instead of 3.7.3?
I've also tried installing Python 3.9.13, but that errors out so I've abandoned that for now.
I have run sudo apt update and sudo apt upgrade, so everything is as up to date as it can be.
BTW, I know very little about Linux, so I know I could have easily screwed things up.
Related
This link
shows that in order to install Kivy with python3.11, you must build your own "wheel". Unfortunately for me, the above install fails at the "make install" command. "which python" seems to confirm that i am in the correct virtual environment, but i am not certain.
So we know for sure that if, as of today, you have the most recent version of python, which is python3.11, then you must build your own wheel for Kivy.
That stackoverflow link doesnt work for me, so I thought, well I will just install python3.7 or python3.8. Unfortunately www.python.org does not have installers for versions lower than 3.9. www.python.org does have python3.7 and python3.8 available but those versions do not have "macOS 64-bit...installer" available for them. i am reluctant to try a python install manually without the installer.
my reading of the Kivy documentation confirms that Kivy is happy with python3.7 or python3.8.
So for me, because I want to use a python version that has an installer on www.python.org, I cannot install Kivy without building my own wheel. And that installation fails for me.
Any advice?
The answer is YES, Kivy installation is possible today without building your own wheel. Use python3.10 as of today, February 8, 2023. Kivy wheels are already built for phthon3.10. I installed Python3.10 from www.python.org on my mac laptop running Monterey 12.6. Then I followed the Kivy install instructions at www.kivy.org. The instructions worked perfectly and now I can run Kivy apps from the command line. Next step is to synchronize my python IDE with the environment variables that were used to install Python3.10 and Kivy.
I've just upgraded to Ubuntu 20.04. I was working with a python 3.7 project using Django inside a virtual environment, so I was confident even with the upgraded distro (which involved the installation of python 3.8) my venv would still worked. Unfortunately, that's not the case: when I activate my venv, the interpreter of python is still the 3.8 version, and nothing works. python 3.7 is completely missing. What can I do to restore my project?
Same problem for me. This is my solution if you do not want to upgrade everything (perhaps not all package are upgradable).
Install python 3.7 which is gone with upgrade to ubuntu 20
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.7
in your virtualenv dir (e.g env/) edit last line in pyenv.cfg
version = 3.7
set back soft link of python3 in env/bin linking back to 3.7
ln -s /usr/bin/python3.7 python3
You may need to delete old symlik before creating new one
Now, should work: it does for me!
In my case, it was solved just by deleting and recreating the virtual env, and reinstalling Django, of course. After that, just reloaded Apache and everything worked again.
I recently bought a new macbook and I've been trying endlessly to get pygame to work, but haven't succeeded yet. I'm getting pretty desperate and I could really use some help.
I've installed pygame 1.9.4 and even though I don't get any error messages when running pygame code, it won't show me anything but a blank screen. I'm using the following code to test it:
import pygame
pygame.init()
screen = pygame.display.set_mode((800,600))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
screen.fill((255,0,0))
pygame.display.update()
pygame.quit()
On my old macbook the test code gives me a red screen as expected. Both macbooks are running python 2.7.10.
Does anyone have any idea what I'm doing wrong? I think I installed pygame exactly like I did on my old macbook and the only difference seems to be the operating system.
edit 1:
I write the script in Sublime Text and run the program in Terminal.
Screenshot
edit 2:
I got pygame working again by downgrading my operating system to macOS High Sierra.
Tested and works on macOS 10.15 Catalina, Python 3.7.5, PyGame 2.0.0 (pre-release as of this writing) and PyGame 1.9.6 (stable as of this writing).
Initially you need to decide if you want a stable release or a pre-release (unstable). If you decide to use the latest (and possibly pre-release/unstable) then just ignore the first step ("1. Find the latest stable release version") and use master branch at step 4 of the second step ("2. Install PyGame from source").
1. Find the latest stable release version
Go to PyGame's GitHub page here:
As you can see as of this writing the latest stable release is 1.9.6 so we hold this tag name for later.
2. Install PyGame on macOS from source
Install some dependencies brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf. This requires homebrew.
Go to site-packages:
For virtual environment go to cd ~/.virtualenvs/myvirtualenv/lib/python3.X/site-packages where ~/.virtualenvs/myvirtualenv is the path to your virtual environment and python3.X is the version of your Python.
For system-wide installation go to /usr/local/lib/python3.X/site-packages where python3.X is the version of your Python.
Delete any previous pygame, pip uninstall pygame (if a pygame directory exists in site-packages then remove it: rm -rf pygame*)
Clone PyGame from GitHub:
git clone https://github.com/pygame/pygame.git for the latest (possibly not stable version).
git clone -b 1.9.6 https://github.com/pygame/pygame.git --single-branch for the latest (1.9.6 is the tag name of the latest stable release, as of this writing, see "Find the latest stable release version above")
Go into the newly cloned pygame directory: cd pygame.
Run python setup.py --config --auto --sdl2.
If you get problems with this command, some users below mentioned that single hyphens worked for them, therefore try: python setup.py -config -auto -sdl2.
If you get any problems regarding Python2/3 and you are targeting Python3 try to change python setup.py --config --auto --sdl2 to python3 setup.py --config --auto --sdl2.
Run python setup.py install (it will take a while).
If you get any problems regarding Python2/3 and you are targeting Python3 try to change python setup.py --config --auto --sdl2 to python3 setup.py --config --auto --sdl2.
Now PyGame should work as expected on macOS.
I also face this problem on the macOS Catalina. Actually it is a version problem of pygame. Firstly I have installed with the following command:
pip3 install pygame
An only blank screen was showing. But later on, I have changed the version with the following command:
pip3 install pygame==2.0.0.dev4
With this version my problem was solved. It was working perfectly.
LATEST UPDATE for MacOS 10.14.1
If you download the official macOS x64 installer package of Python 3.7.2 from the official python.org page and type pip3 install pygame, it works.
There's an issue with MacOS. It should be possible to fix in SDL.
https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060/8
https://bugzilla.libsdl.org/show_bug.cgi?id=4274
The pygame issue is here: https://github.com/pygame/pygame/issues/555
The homebrew issue is here: https://github.com/Homebrew/homebrew-core/issues/33016
I ran into this issue using macOS Catalina version 10.15.2, Python 3.7.2 and pygame 1.9.6. I upgraded to Python 3.8.1, Pygame 2.0.0.dev6 and it is now working as expected.
I tried upgrading my old macbook to OS Mojave to see if pygame would stop working, and it did!
I guess Mojave isn't compatible with pygame (yet).
Thanks for the help!
Edit with working workaround:
see bottom of post
I get the same problem on a MacBook Pro (Retina display) with python3.7 and MacOs Mojave.
For the sake of simplicity, I did all my tests with your exact same code and pygame 1.9.4.
On (two) Windows computers, the program works and shows a red window on :
python2.7
python3.6
python3.7
Hence it doesn't seem to be a Python version problem, I lean toward a MacOS Mojave problem.
Mojave introduced 'Dark mode' which automatically tint windows. When dark mode is disabled, I get a blank screen. When it is enabled, I get a dark screen. Might it be that MacOS takes control of the screen display and fiddles with the way pygame controls the screen? It is just a theory but I don't know how to test it.
Edit:
I tried a pygame program that records and prints the position of the screen on which you clicked. It does output the position in the console, alas it doesn't display anything.
Apart from the faulty display, pygame seems to work properly.
Edit:
For now, using the Python version from miniconda and using CogSci's pygame seems to work.
I've tried everything but nothing worked except this:
pip install git+https://github.com/pygame/pygame.git
This installs the tips of the pygame. It worked for me. Give it a try.
I ran into this problem with the following environment: Python 3.7, Mojave 10.14.2, Pygame 1.9.4
I found that downgrading to Python 3.6 fixes the issue
$ brew unlink python
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
That should fix it, if you get a circular dependency problem you should then run:
$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
Details at https://apple.stackexchange.com/questions/329187/homebrew-rollback-from-python-3-7-to-python-3-6-5-x
I had the same issue, got it to work by downgrading python to 3.6.5.
> brew unlink python brew install --ignore-dependencies
> https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
> brew switch python 3.6.5_1 pip3 install pygame
If you already have python 3.6.5 install I guess you can just use switch.
Some macs need updates. If you go to system preferences and you go to software updates, you could try updating to see if it needs any updates. When you update, you can check to see if your code works now because it looks like your code is correct.
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.
Following the steps given here, i have completed the installation process, however Python (IDLE) is giving me an ImportError. For which the guide suggests :
Python may return to you an error like "No module named cv" The trouble is that the python module is installed in /usr/local/lib/python2.6/site-packages. But, on Debian and on Ubuntu, Python only looks in /usr/local/lib/python2.6/dist-packages
You can fix it using three ways (Use only one of those, the first is the best):
move the cv.so file from the site-packages to the dist-packages:
sudo mv /usr/local/lib/python2.6/site-packages/cv.so /usr/local/lib/python2.6/dist-packages/cv.so
However, both the site-packages as well as dist-packages, for both 2.7 and 3.2 are empty.
What went wrong and how do i solve it ?
I solved the problem by installing all the packages and dependencies again using the Software Center. OpenCV Python bindings are available for OpenCV 2.3 and Python 2.7 directly from the software center which I used the second time.
OpenCv python bindings for 3.2 are not available for 12.04. They are being developed for Raring (Ubuntu 13.04) only. Hence, the solution is to use either backports, or to use OpenCv on Python 2.7
Backports also have a problem as they are available only for 32 bit OS systems and not 64 bit.
So, the only safe and stable way to run OpenCV Python on Ubuntu seems to be using OpenCV 2.3 on Python 2.7
I also get the empty dist-packages folder with OpenCV2.4.4 and Ubuntu 12.04. It turns out that I need to install python-dev and python-numpy in order to make the cv.so compiled into the dist-packages.
sudo apt-get install python-dev python-numpy
After that, using cmake to build OpenCV again and everything will be fine
UPDATE
it depends on your system pretty much.
On my Lion (10.8), I have java installed, and openCV complaints about cannot build the unit test and stop at 92%. It turned out that I have to manually create the build folder and put the junit jar into the lib folder in order to let opencv compile all the test case. After that, everything is ok
On my ubuntu (12.04, fresh installation with build-essential and all packages are up-to-date), eveything is compiled fine, except that "No module named cv" and there is not cv.so in the dist-packages and site-packages. Searching around and then finally, it turned out that I have to have python-dev and python-numpy