Everything went well while I was trying to create a ros 2 package in Ubuntu 22.04 by following the ros2 documentation, however when I got to the colcon build step, it failed for python packages even though it works for cMake packages.
colcon build --packages-select mypkgpython
...
import distutils.command.bdist_wininst as orig
ModuleNotFoundError: No module named 'distutils.command.bdist_wininst'
knowing that my python version is:
python3 --version
Python 3.10.6
i have tried:
sudo apt-get install python3-distutils:
python3-distutils is already the newest version (3.10.6-1~22.04).
sudo apt-get install python3-apt:
python3-apt is already the newest version (2.4.0).
sudo apt install python3-colcon-common-extensions
python3-colcon-common-extensions is already the newest version(0.3.0-1)
how can i solve this problem?
i expected when i build my python package using
colcon build package
it will be successfully build, so i could work with
The bdist_wininst command was deprecated in Python 3.8 and you are using python 3.10
Its no more found in python3-distutils package .
use
bdist_wheel (wheel packages) instead
or
if you want to run your code as it is downgrade your python to < 3.8
The bdist_wininst format was deprecated in Python 3.8, and the documentation for this format has been removed in Python 3.9. The recommended way to distribute Python packages now is the Wheel format.
you can overcome this error by JUST updating the setuptools
pip install --upgrade setuptools
Note that: Setuptools version 58.2.0 is the last version that works with ROS 2 python packages without any warnings because it is the last version that supports the old installation method, "python setup.py install." This method has been deprecated and replaced by newer, standards-based tools, such as pip and ament.
pip install setuptools==58.2.0
Related
I am unable to get dateutil installed in my Python code.
from dateutil import tz
ImportError: No module named dateutil
I had date-util installed (Python version is 3.7.3)
> pip3 install python-dateutil
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: python-dateutil in /usr/lib/python3/dist-packages (2.7.3)
I cannot uninstall them (to reinstall). I get the following error
> sudo pip3 uninstall python-dateutil
Not uninstalling python-dateutil at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'python-dateutil'. No files were found to uninstall.
Then, I used the following command to uninstall:
> sudo apt-get remove python3-dateutil #This worked
> pip3 install python-dateutil
This works, but asks me to install cycler, kiwisolver, pyparsing, which I install using pip3. But I still cant get the python code working - has the same error (ImportError: No module named dateutil)
Any suggestions on what's going on?
I found a solution - The python code is being called from a bash script. It worked fine until recently. Recently I installed some other packages that installed python 2.x. So, the python scripts were using Python 2.x rather than 3.x. I had symbolic links to python 3.x, but that didn't help.
Now, I am explicitly use python3 mycode.py to overcome this issue.
I highly recommend to use conda environment instead of pip. See, there are several modules which do not give expected behaviour in pip (like pytorch).
Get the package installed using:
conda install -c conda-forge python-dateutil
returning the question, to get the package running it requires fulfillment of it's dependencies. If you are using python 3.7.3 its obvious that it may lack in some of the features of modern python 3.11 as a result you get the obvious error. The python package python-dateutil must have been configured according to the modern python language version.
Iam using python 3.11.1 and the package gets installed very perfectly. You may install old version of package or upgrade your python language version or use Conda as mentioned before.
I am unable to find or locate python in osx. but python3 works. however my pip packages are all installed not sure how with pip and not pip3. Any idea how I can use my pip packages with python3 and not having to installed them again with pip3? I believe python3 was installed via brew
% brew list
==> Formulae
autoconf kubernetes-cli mpdecimal python#3.10 virtualenv
ca-certificates libidn2 openssl#1.1 readline wget
gdbm libunistring pkg-config six xz
gettext m4 pyenv sqlite
==> Casks
mysqlworkbench virtualbox
vagrant visual-studio-code
You can use which python3 to locate your python installation
If your packages were installed for a different version of Python, they are very likely not compatible with your current version of Python, especially if you were using Python 2 before and now using Python 3. If you want to try to keep all your current packages, use pip freeze to export your current list of installed packages, remove the version numbers, and reinstall them using the pip of the Python distribution of your choice.
My problem is that when I try to install a product that requires python >= 3.7, the installer fails, saying that it could not find the required python version, even though I do have python 3.8 installed.
I'm running Ubuntu for Windows 10 (the MS-store product.)
It comes with python 3.6 installed.
From a clean ubuntu install, I
sudo apt update
sudo apt install python3.8
sudo apt install python3-pip
At this point the command "python" is not mapped (not available), but I can run "python3" to get python3.6 or "python3.8" to get that version.
pip3 reports that it is using python 3.6.
pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
So it appears that pip is not recognizing the python 3.8 that I have.
When I attempt my product install, it fails, indicating that
sudo pip3 install --verbose (mypackage name)
(... various messages...)
(requires-python:>=3.7) is incompatible with the pythonversion in use. Acceptable python versions are:>=3.7
Could not find a version that satisfies the requirement cbordplatform (from versions: )
No matching distribution found for (my package name)
How can I get pip3 to recognize my python3.8?
If you want to make sure that pip is using the correct version of Python, call it with the specific Python like this:
python3.8 -m pip ...
i want to play with the lunar lander env from OpenAI gym.
In order to run this code I need to install Box2d, this is where my problems arise.
I am using ubuntu 16.04 with conda 4.3.21 and python 3.6.
When I tried to run the environment I received the error: ModuleNotFoundError: No module named '_Box2D'
So I tried the direct install of pybox2d:
https://github.com/pybox2d/pybox2d/blob/master/INSTALL.md
which yielded the same error message.
Then I tried to install from GitHub following the way outlined in https://github.com/cbfinn/gps/issues/34
$git clone https://github.com/pybox2d/pybox2d pybox2d_dev
$cd pybox2d_dev
$python setup.py build
$sudo python setup.py install
If I run this (in root environment which has python 3 or another new created environment with python 3) i get the result:
a lot of processing logs
Processing Box2D-2.3.2-py2.7-linux-x86_64.egg
creating /usr/local/lib/python2.7/dist-packages/Box2D-2.3.2-py2.7-linux-x86_64.egg
Extracting Box2D-2.3.2-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
Adding Box2D 2.3.2 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/Box2D-2.3.2-py2.7-linux-x86_64.egg
Processing dependencies for Box2D==2.3.2
Finished processing dependencies for Box2D==2.3.2
So pybox2d is installed into the lib of the standard python 2 of ubuntu despite being in a python 3 conda environment.
So, I am looking for ways to install the pybox2d package for python 3 with conda 4.3.21
Installing Box2D from pip led me to the error described here when I tried to import it. Here's what worked for me on Python 3.6, as suggested in that GitHub issue:
conda install swig # needed to build Box2D in the pip install
pip install box2d-py # a repackaged version of pybox2d
Hey this question looks quite old but it seems no one really put the right answer in any where so just write this.
Follow the below two lines on your linux command:
$ sudo apt-get install build-essential python-dev swig python-pygame
$ pip install Box2D
---------Below is unnecessary details --------
Many wants to run Box2D based gym but it is sth you have to install by yourself like Mujoco series gym envs.
Many uses python 3.6 but the easiest way of installing Box2D, which is
$ conda install -c kne pybox2d
doesn't work cuz pybox2d has been maintained til py3.5
But directly doing
$ pip install Box2D
does not solve the issue. The error comes from swig given its error msg, but it's actually not.
$ sudo apt-get install build-essential python-dev swig python-pygame
This line always solve everything in one go.
I have been doing research based on Box2D envs but still foget this everytime I install this in a new env, so this is for me as well lol
Contribute: https://github.com/jonasschneider/box2d-py/blob/master/INSTALL.md
Btw, do not forget to double-check whether it is properly install.
In linux command
$ python --version
python 3.6. sthsth
$ python
>>> import numpy as np
>>> import gym
>>> env = gym.make('BipedalWalker-v2')
# If it does not give you error, then it's done!
You need to activate your environment:
source activate my_env_name
Then prompt changes to:
(my_env_name)
Now, install with pip and without sudo:
pip install pybox2d
sudo apt-get install swig
pip install pybox2d
Installing this way worked for me (also in a virtual env):
pip install box2d-py==2.3.8
I am running gym v 0.17.3.
I'm trying to install packages for my python 3.5.0 versus my python 3.4.3
I can run both by typing either python3.4 or python3.5
I have pip2 and pip3. I also ran the script sudo easy_install3 pip, which made me be able to use pip3.4 But I am still having trouble installing modules for python3.5. pip3 just installs for python3.4
I am looking to install termcolor for python3.5 and I am having no success. Can anyone help?
I am on Windows, and you appear not to be, but maybe the following will help.
If pip is in your system's equivalent of python35/Lib/site-packages, then python3.5 -m pip should run pip so that it installs into the 3.5 site-packages.
If you do not have pip in the 3.5 site-packages, copy its directory, along with its dependencies (pip....dist-info/, setuptools/, setuptools....dist-info/, and easyinstall.py) from the 3.4 site_packages.
Or, if pip3 or even pip3.4 is in python35/Scripts, run it with its full path name so you are not running the 3.4 version.