ImportError: No module named 'setuptools' in wsl - python-3.x

I am using wsl and Debian distribution; when I'm trying to install pybrain through setup.py getting an error; ImportError: No module named 'setuptools.'I have already installed setuptools into my system still getting the same error.
I have used the following commands.
sudo python3 setup.py install
sudo apt-get install python3-setuptools
enter image description here

Related

ModuleNotFoundError: No module named 'uaclient.entitlements' dpkg: error processing package ubuntu-advantage-tools (--configure):

Whenever i try sudo apt-get upgrade or try to install any other package i get the above error. Is there any way to solve it?? Using ubuntu 16.04
Removing python3-distro-info (0.14ubuntu0.2) ...
Setting up ubuntu-advantage-tools (27.0~16.04.1) ...
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'uaclient.entitlements'
dpkg: error processing package ubuntu-advantage-tools (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
ubuntu-advantage-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)
You should install opcua and opcua-client with default python command:
python -m pip install --upgrade opcua
python -m pip install --upgrade opcua-client
I have the same problem and try to solve then it work for me.
My environment:
OS: ubuntu 18.04 LTS
python version: 3.6.9(system default) , manual
install 3.8.7
System python path have been link to python 3.8 when I install python 3.8, so any process use python will call python 3.8 and use pip3.8 site-packages, not use system dist-packages(python 3.6). But python 3.8 uaclinet(install by pip) is different from uaclinet in dist-packages(ubuntu-advantage-tools provide). then I use apt upgrade
設定 ubuntu-advantage-tools (27.0.2~18.04.1) ...
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'uaclient.entitlements'
dpkg: error processing package ubuntu-advantage-tools (--configure):
installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
處理時發生錯誤:
ubuntu-advantage-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)
So, I copy the uaclinet(in dist-packages) to python 3.8 site-packages and run upgrade again, then it works( maybe has compatibility problems )
設定 ubuntu-advantage-tools (27.0.2~18.04.1) ...
W: APT had planned for dpkg to do more than it reported back (0 vs 4).
Affected packages: ubuntu-advantage-tools:amd64
I think if your use system python , you can use comment by Jan Wilamowski,
This problem appeared for me after upgrading to Ubuntu 18.04 from 16.04.
I updated opcua and opcua-client as suggested with python -m pip install, and also with pip3 install, to get it updated in python3 packages, and the problem remained.
I have system python3 installed in /usr/bin/python3 (version 3.6), and another version in /usr/local/bin/python3 (version 3.8) which is the default python3. I'm not sure why, but the uaclient.entitlements module can be loaded properly with /usr/bin/python3, but not with /usr/local/bin/python3
Instead of changing the location of the uaclient package, the following worked for me:
I used update-alternatives to choose which python3 will be used by default, either system python3 which is /usr/bin/python3.6, or the updated python3 which is installed in /usr/local/bin/python3.8 as described here:
https://unix.stackexchange.com/questions/410579/change-the-python3-default-version-in-ubuntu
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/local/bin/python3 python3 /usr/local/bin/python3.8 2
Then, choose /usr/bin/python3.6 as the default by running:
sudo update-alternatives --config python3
A symlink is created as /etc/alternatives/python3 that points to the chosen default python3.
Since the way I set the alternatives results in /usr/local/bin/python3.8 as the automatic default python3, the symlink /usr/bin/python3 -> python3.6 is removed. But this symlink is still needed for dependencies/functions that use system python through /usr/bin/python3, so I added back the sym link:
sudo ln -s python3.6 /usr/bin/python3
By setting /usr/bin/python3.6 as the default instead of /usr/local/bin/python3.8, then uaclient.entitlements can be loaded properly. This worked for me to install and upgrade packages where this uaclient.entitlements ModuleNotFoundError was occurring. Just have to switch back to using /usr/local/bin/python3.8 when finished installing. But I think now that ubuntu-advantage-tools is configured by getting through this error, there doesn't seem to be a need to switch to /usr/bin/python3.6 as the default anymore for installing packages.
The answer in https://askubuntu.com/questions/1336425/no-module-named-uaclient-during-sudo-apt-upgrade-ubuntu-16-04 worked for me. Basically, I modified manually the post-installation and pre-remove script in /var/lib/dpkg/info/ubuntu-advantage-tools.postinst and /var/lib/dpkg/info/ubuntu-advantage-tools.prerm and replace python3 with the complete path /usr/bin/python3.5, and then the 'apt-get upgrade' didn't fail as before.
If you are not going to use ubuntu advantage tools then
sudo dpkg --remove --force-remove-reinstreq ubuntu-advantage-tools
but even tat failed for me... I had to
sudo rm /var/lib/dpkg/info/ubuntu-advantage-tools.prerm
because this script was blocking uninstall
i have tried to install:
python -m pip install --upgrade opcua
python -m pip install --upgrade opcua-client
but even that was failing for me on a second - client installation
finally after about 6 months I can do ubuntu update without error reporting.

How to install fenics in Ubuntu using PIP for a particular python environment?

I want to install fenics in Ubuntu 20.
First I made a python environment using:
sudo apt install python3-venv
Then inside the folder I want to make an environment I open a terminal and use:
python3 -m venv myproject
myproject is the name of the environment I made.
I then activate my environment:
source myproject/bin/activate
To install fenics for this particular environment while I activated the environment, I use:
pip install fenics
I verify the installation using pip list which returns:
Package Version
-------------- --------------
fenics 2019.1.0
fenics-dijitso 2019.1.0
fenics-ffc 2019.1.0.post0
fenics-fiat 2019.1.0
fenics-ufl 2019.1.0
mpmath 1.1.0
numpy 1.19.4
pip 20.0.2
pkg-resources 0.0.0
setuptools 44.0.0
sympy 1.7.1
I try to import fenics using:
python -c "import fenics"
But I get the error below stating there is not fenics module:
raceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'fenics'
What is the problem? Hopefully, after successful installation of fenics, I can install Spyder and other python packages and will be able to use fenics inside spyder.
Edit
I want to install fenics in a python virtual environment.
The issue here is that fenics is just a meta-package and it does not contain any library that you can use in your Python code.
Quoting from the README for the fenics project :
This package contains a single file, setup.py, that allows all of the FEniCS Python components to be installed from PyPI using pip:
pip3 install fenics
Actual use of the library is done via
import ffc
All different components are under this package. For example, fenics-fiat is available as ffc.fiatinterface.
Fenics library of python
If you have installed pip than you have to use pip install fenics. If you have installed pip3 than `pip3 install fenics
I have already installed both.
sudo apt update
sudo apt install python3-pip
Install pip for Python 2 with:
sudo apt install python-pip
After doing pip3 install fenics,write python3 -c import ffc to import it. If this works, it has been imported. It is called ffc, not fenics

Unable to install pyinstaller in Ubuntu 16 with Python3.5

I have ubuntu16 which comes with python3.5 pre installed. I have installed pyinstaller using:
sudo pip3 install pyinstaller
It ran fine and installed pyinstaller. After that I ran, pyinstaller it says command not found.
I also tried installing it like:
sudo python3 -m pip install pyinstaller
It ran fine and said requirement already satisfied. But was unable to run pyinstaller.
I then upgraded the pip using sudo python3 -m pip install --upgrade pip and then reinstalled pyinstaller but this time used --user flag:
sudo python3 -m pip install pyinstaller --user
After this command it installed pyinstaller along with some other packages too.
Now if I run pyinstaller on terminal, I get this error:
Traceback (most recent call last):
File "/home/andrew/.local/bin/pyinstaller", line 5, in <module>
from PyInstaller.__main__ import run
ImportError: No module named 'PyInstaller'
Running the command sudo python3 -m pip list to get all the installed packages, I can see pyinstaller in the list:
pycurl 7.43.0
pygobject 3.20.0
pyinstaller 4.0
pyinstaller-hooks-contrib 2020.9
PyJWT 1.3.0
I am really confused as to what I should do in order to successfully install and run pyinstaller. Can anyone please help and suggest some good working solutions. Thanks
Okay I think I have finally managed to run pyinstaller on ubuntu16.
I am not sure if its the issue with Ubuntu16 or python3.5, but we need to upgrade the python version. So I first installed python3.6 using below commands:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
After the installation, I made sure that running python3 is invoking the python3.6 and not python3.5:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
sudo update-alternatives --config python3
After this if you type in python3, it should launch python3.6.
Once this is all done, just upgrade pip :
sudo python3 -m pip install --upgrade pip
after that you can install pyinstaller:
sudo pip3 install pyinstaller
also run this command:
sudo apt-get install python3.6-dev
otherwise you will get python lib not found error in pyinstaller build
and it will install and work fine.
I think pyinstaller is not working with python3.5 as this python version is also deprecated. So we need to upgrade the python version. So if any one is on ubuntu16 which has python3.5 as default, just upgrade your python version.

MoudleNotFoundError: No module named 'spinup.utils'

I'm doing installation from spinningup page.
I wrote
python -m spinup.run ppo --hid "[32,32]" --env LunarLander-v2 --exp_name installtest --gamma 0.999
but error occured
ModuleNotFoundError: No module named 'spinup.utils'
And i tried to install spinup and utils,
pip install spinup
pip install utils
and it says,
Requirement already satisfied
So these are not answer for error.
How can i solve spinup.utils error?
linux terminal error image
install spinningup again
cd spinningup
pip install -e

Python3 permissions and installing ipython/jupyter extensions

My question is two-fold, but I believe they are related:
I have recently realized that I have a permission issue with my python3 installation. If I run python3, I cannot import any packages. However, if I run sudo python3, all packages import flawlessly. Similarly, I must run jupyter notebooks with sudo as well. From reading, I believe I have made an error by installing many packages with sudo pip. Is there a straightforward way to fix this?
I am trying to install ipython extensions without luck. Using
sudo pip install https://github.com/ipython-contrib/IPython-notebook-extensions/archive/master.zip --user
I receive an error error: command 'x86_64-linux-gnu-gcc' failed with exit status 1.
If I download the zip file, and run sudo python3 setup.py install, the error is:
IPython-notebook-extensions/configure_nbextensions.py", line 80, in <module>
except (psutil.ZombieProcess, psutil.AccessDenied):
AttributeError: 'module' object has no attribute 'ZombieProcess'
If I run python setup.py install, the resulting error is:
File "/usr/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
This is the same error that I get when importing a package from python (when opened with python, rather than sudo python) in the terminal.
I am using Ubuntu 14.04.
except (psutil.ZombieProcess, psutil.AccessDenied):
AttributeError: 'module' object has no attribute 'ZombieProcess'
From the message,The old version of psutil is missing these module.
you should update the package of psutil use:
sudo pip3 install --upgrade psutil

Resources