I try installing python with
pyenv install 3.11.0
(though this happens no matter the version) on my Raspberry Pi. When the install is running, there's a 3.11.0 directory in ~/.pyenv/versions, pyenv versions recognizes it, and the installed python is actually usable, but the dir disappears after the installation process finished.
Raspberry Pi OS - Debian GNU/Linux 11 (bullseye) aarch64
Aside from one time when it errored out, this has happened every time I tried installing, including 3.11, 3.10, 3.9 and 3.8
I have tried:
Installing python 3.11, 3.10, 3.9 and 3.8, so I dont think it will work with any other version
Reinstalling pyenv and its dependencies multiple times
One possible cause of this issue is that there is a conflict between pyenv and another tool that you have installed on your Raspberry Pi. For example, if you have another version of Python installed on your system, it is possible that this version is overwriting the directories created by pyenv.
Another possible cause is a permissions issue. If the user account that you are using to install Python does not have the correct permissions to create and modify directories, this could cause the directories to be deleted after they are created.
To troubleshoot this issue, you may want to try the following steps:
Check to see if you have any other versions of Python installed on your system. If you do, try uninstalling them and then re-installing the versions of Python that you want to use with pyenv.
Check the permissions for the ~/.pyenv/versions directory. Make sure that the user account that you are using to install Python has permission to create and modify files in this directory.
Try installing a different version of Python, such as Python 3.8. This will help you determine if the issue is specific to certain versions of Python, or if it occurs with all versions.
If you are still experiencing issues, you may want to try uninstalling pyenv and then reinstalling it from scratch. This will reset the configuration of pyenv and may help resolve any underlying issues with the tool.
Related
I have a Raspberry Pi 3 with Raspbian and I upgraded python version from 3.7 to 3.8. If I type python --version in the terminal the correct version appears as the system version. However none of the modules that I have installed AFTER the version change seem to work. Python gives ModuleNotFoundError when trying to import ANY of the modules that I have installed.
I can see the modules with pip freeze but Python seems to not be able to find them.
I followed this instructions to purge 3.7. I reinstalled pip after purging python 3.7 but pip as again installed in /home/pi/.local/lib/python3.7/site-packages/pip. How can I get rid of 3.7 completely?
python3.8 -m pip install SomePackage # specifically Python 3.8 should work.
More documentation here: https://docs.python.org/3/installing/index.html#work-with-multiple-versions-of-python-installed-in-parallel
Just to summarize the comments and suggestions from other answers:
The problem I have was caused by the fact that even I had set Python 3.8 as default and python -v was pointing to Python 3.8 the pip script was installing modules for Python 3.7.
The suggested solution was to use pip3.8 (or whatever version someone might have) to install packages for that equivalent Python version and that works good.
Ideally best option if someone wants to have multiple versions of python is to use pyenv. You can create multiple virtual environments with multiple python versions.
However Do not uninstall the default Python. I have also tried to uninstall the default Python 3.7 to avoid having two versions of python 3 and keeping track of which module is installed where. This was a bad idea. I did not know that many Linux distributions have applications which use the default Python. You might get a black screen and who knows what other problems see this discussion Removed Python 3 on 18.04, how can I fix my system?
I'm quite new to Ubuntu. On my machine, running Ubuntu 20.04 with Python 3.8, I'm trying to run a program which does not support Python 3.8, but it requires Python 3.7 (FYI, it is Carla Simulator).
I need pygame, but when installing it through pip (python3.7 -m pip install pygame) it raises an error:
ModuleNotFoundError: No module named 'distutils.util'
Now, I have distutils correctly installed and updated at version 3.8.2-1ubuntu1.
Is there any way for me to install a distutils version compatible with Python 3.7 without affecting Python 3.8 and related modules? Or do you have hany suggestion to get pygame for Python 3.7 and running Carla somehow? Could a virtual environment help?
My question is really similar to this one How to install python-distutils but I don't actually require distutils, I just need the program to work...
Thank you
----- EDIT -----
I tried creating a virtual environment using venv, but I got an error due tue unavailability of ensurepip. Googling it, I found it might be related to the fact that my Python 3.7 version might have been installed through Anaconda (I actually can't remember). Running apt-cache rdepends python3.7 I get:
python3.7
Reverse Depends:
python3.7-minimal
Is it safe to completely uninstall current Python3.7 and reinstall it to hopefully get ensurepip? Any suggested code to safely do it?
The easiest solution for you would be to run your program in a virtual environment where you would specify the default python version to be 3.7 I think (see Use different Python version with virtualenv for an example). You can then install all your dependencies inside this environment and not have to deal with any conflicts between the two versions on Python.
Using pyenv you could specify the python version you want to use.
for example:
create a new folder and hit:
pyenv local 3.7.2
then create your virtual env by using pipenv:
pipenv install
then start your journey to building your game.
hope it help.
I'm trying to follow the instructions here but no matter what I do it seems to be stuck on using Python 2.7.1 which is causing me errors currently.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html
Attached is an image showing my logs of upgrading to the newest awsebccli but its still stuck saying 2.7.1 when it should say 3.6 (or newer)
What could I be doing wrong?
I want to note that I also installed the newest version of python3 and python via brew.
Here is the exact error I'm getting if it helps also.
You do not want to upgrade the default python 2.7x installation or the python 3.x installation available on linux or OSX. There are usually lots of other libraries and applications that depend on this default installation. When you want to use a specific version of python the approach is to rely on a virtual enviorenment.
virtualenv is a tool to create isolated Python environments.
You are then leaving the system installation untouched. Getting the hang of virtualenv is quite easy. Once you create it (a one off task). All you need is to activate it and then you can use it as you would normally use the default python interpreter. How to copy packages from one virtualenv (or the system installation) to another is discussed here:
Installing python3 in a python2 virtual environment
I'm new to python. I installed python3.4 on OsX some time ago and now I installed python3.5 using the installer you can download from the site.
I noticed that in /Library/Frameworks/Python.framework/Versions/ I have both 3.4 and 3.5. I wasn't expecting that - I was expecting an upgrade where 3.5 replaced 3.4
So, if I run python3.5 and I try to import the packages I installed when using 3.4, they are not found. Furthermore if I use pip install to reinstall them, it says the packages are already installed, therefore I can see that it's pointing to the 3.4 version.
What I'm doing wrong? I supposed that installing the new python should upgrade my existing installation (bringing installed packages with it) rather than add a completely new install.
I'm not sure what to do now:
Should I keep every old version?
Should I manually change which pip
is used every time?
(is there a more streamlined update procedure
for next time?)
A lot of Python packages are 3rd party. The community is always moving forward and this may take some getting used to!
That said, my recommendation is to start using venv. It gives you (mostly) isolated Python virtual environments in which you can install whatever packages you like (via pip) without polluting the global installation. This also allows you to configure various virtual environments with varying packages and versions. It's really handy!
Link:
https://docs.python.org/3.4/library/venv.html
I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch.
After just installing Python 2.7, and easy_install with setuptools for 2.7, this all in turn created such a mess that is unbelievable. Different version of Python are installed everywhere, easy_install is installed everywhere and points randomly to different python hashbangs (sometimes to #!/usr/bin, #!/usr/local/, #!/Library/...)
Now I can't even do easy_install pip, which I always could. So I'm already in a hell and I haven't even attempted to install MySQL yet.
My question finally is did anyone bump into such problems, it would help enough to know that I'm not alone.
Second, would it be easier to set up the entire environment on Ubuntu than it is on a Mac?
Thirdly, is there any guide that can really clearly explain how to set up but also tear down the stack for Python development on a Mac?
It wouldn't hurt to run a VM with vagrant. This post should tell you more:
http://stevelosh.com/blog/2011/06/django-advice/
Of course using virtualenv should also help alleviate some of these issues.
I've gone through the same hell 2 weeks ago :)
I needed to make working python 2.7 and virtualenv on OSX 10.6.8.
You haven't mentioned virtualenv in your question but I strongly recommend it. That way you minimize amount of globally installed packages. Everything is... cleaner.
My idea is to only have following things globally:
python (from brew)
pip (via easy_install)
virtualenv (via pip)
virtualenvwrapper (via pip)
other through either virtualenv or buildout
I've just checked and pip PIL installs fine within my virtualenv.
Here are notes from this battle (gist.github.com):
#NOTE: .pydistutils.cfg seems to be not compatible with brew install python
#areas I needed to clean before installation
#clean up ~/Library/Python
#clean up .local
brew install python
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs
Example .bash_profile:
#homebrew
export PATH=/usr/local/bin:/usr/local/sbin:${PATH}
# homebrew python 2.7
export PATH="/usr/local/share/python:${PATH}"
#virtualenv wrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python/virtualenvwrapper.sh
Good luck!
Second, would it be easier to set up
the entire environment on Ubuntu than
it is on a Mac?
To answer this question (though I never used Mac though): I never had problems setting up a python environment for Django development on Ubuntu. Though in any case you should go with the built-in Python version if possible. Attempting to install any other Python versions usually ends up messy. Luckily with Ubuntu 11.04 the standard version is already 2.7.
I'm using django development environment on a MAC OS X 10.8 with python 2.7. I don't use virtualenv ore some other things.
With all the respect can say that there is NO ANY PROBLEMS to develop on a mac. Mac is a UNIX like system and you've probably seen that all tools for developers have MAC ports.
As for the setup mess. It's a good idea to use virtualenv. As for PIL installation. I needed to compile it with TrueType. As I'm in common with UNIX like environments it was not heavy task for me to compile PIL from sources using GCC (it's already installed on a MAC)... There are some mess with Django to setup virtualenv... There are certainly lots of articles to setup it on Google.
I use Eclipse and write all my PYTHONPATH variables there. You can forget installing everything like in Linux and try not to make anymore mess with installed tools. Try to read THIS article if you feel like you're ok to use Eclipse for your development on a MAC. It also has a recipe to avoid mess with installation of many copies of Python and other dev utils.
Yes I have had problems with MacOS. I think rather than trying to figure it out I just switched to Ubuntu. I use a mac with Ubuntu installed in VMware Fusion. I have developed on both and prefer the Ubuntu because I'm just more comfortable with installing packages and the file structure.
I love using the VM because I'm never scared of having to start over. I can get a whole new OS installed and get the packages with what I use in just a few hours. Not to mention with 6month rollouts I can do complete installs of new versions instead of updates.
Depending on your production environment, it may be beneficial to use an OS that is similar, if you can install a package on ubuntu desktop, you already know how to do it on ubuntu server.