IPython parent '/' is not a writable location - python-3.x

I am following this guideline to troubleshoot my atom+hydrogen installation:
https://nteract.gitbooks.io/hydrogen/content/docs/Troubleshooting.html
Specifically, trying to run this part:
python3 -m pip install ipykernel
python3 -m ipykernel install --user
after running the python3 -m ipykernel install --user I get the following error:
/Library/Python/3.9/lib/python/site-packages/IPython/paths.py:66: UserWarning: IPython parent '/' is not a writable location, using a temp directory.
warn("IPython parent '{0}' is not a writable location,"
Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3
I am wondering what this error actually means and how I can get around it. I ran this code with sudo as well but it didn't help

Related

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.

pip3 install error when I use virtulenv as general user

I found the following problem when I tried to install the package using the pip3 command in a virtual environment.
source /bin/activate ##activate virtualenv
pip3 install aiohttp ##
error: Could not install packages due to an EnvironmentError: [Errno
13] Permission denied:
'/home/yxs/venv/py34/lib64/python3.4/site-packages/multidict' Consider
using the --user option or check the permissions.
pip3 install --user aiohttp
error: Can not perform a '--user' install. User site-packages are not
visible in this virtualenv.
So, I tried sudo pip3 install aiohttp,When I checked with pip3 list, I found that aiohttp was installed in the system. Beacause
(py34) [yxs#yxs ~]$pip3 list ## no package named aiohttp
[yxs#yxs ~]$pip3 list ## found aiohttp
How can I install packages into virtualenv?
Edit:
The operating system is CentOS7.5, the default Python version is 2.7, I installed python3.4 through epel-realse, pip3 installed by get-pip.py.
I guess the problem is that I have to use command sudo to install, but this command will leave the virtualenv environment. Just like the following, but I don't know how to solve this problem. By the way, these operations are excuted in the tmux session.
(py34) [yxs#yxs ~]$su - root
Password:
Last login: Wed Sep 19 12:07:23 CST 2018 on pts/2
[root#yxs ~]#
All in all, I can only use root to install the package into virtualenv by command pip install
Source /bin/activate means you're using /bin root directory of unix/linux.
As you're using python 3. Why don't you use python's builtin venv module.
Add .env directory into your .gitignore file.
Usage
python3 -m venv .env
source .env/bin/activate
pip install django
pip freeze > requirements.txt

Python3 wheel returns error : not a supported wheel on this platform

I would like to install wxPython/4.0.1
On this page all kind of wheel files are shown. I have Ubuntu 14.04 64 bit and Python 3.5 so I assume I should use wxPython-4.0.1-cp35-cp35m-win32.whl but this is not total clear to me.
The page lacks a simple full installation instruction.
#nepix32 helped me and shown the Linux version https://wxpython.org/pages/downloads/ and I have been pointing to https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04/
apt-get
My preference is using apt-get, so I search on SO and found : Installing wxpython on ubuntu 14.04 and using travis-ci with wxpython tests
which both fails.
So I continue searching on wheel.
Install wheel
So I continue searching on wheel. On SO I found : How do I install a Python package with a .whl file?6
First I read https://stackoverflow.com/tags/python-wheel/info and https://pypi.python.org/pypi/wheel
Wheel seems not standard installed, so I downloaded the file wheel-0.30.0 and extracted it.
First I upgraded pip :
sudo pip install --upgrade pip
and then executed the setup.py in wheel :
sudo python3.5 setup.py install
which seems successful.
Try to install wxpython using wheel
Then I wanted to install the wheel file :
sudo pip install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-win32.whl
I thought for python3.x pip3 should be used, instead of pip. All examples show pip. I tried both without success.
I tried also :
sudo -H pip3 install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-win32.whl
All attemps returned almost the same error message :
wxPython-4.0.1-cp35-cp35m-win32.whl is not a supported wheel on this platform.
Using specific Linux version
I used
wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl
but do not know the difference of the 'm' and the 'mu' version. The result is :
sudo pip install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl wxPython
The directory '/home/hulsman/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/hulsman/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl is not a supported wheel on this platform.
hulsman#vbox11:~/Downloads$
and with the -H flag :
hulsman#vbox11:~/Downloads$ sudo -H pip install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl wxPython
wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl is not a supported wheel on this platform.
hulsman#vbox11:~
Check my environment
$ pip -V | grep -o "(.*)"
(python 3.4)
Pip points to Python3.4
$ pip3.5 install -i https://localhost --trusted-host localhost cffi==1.11.4
pip3.5: command not found
pip3.5 does not exist
$ python3.5 -c "import pip; print(pip.pep425tags.get_abbr_imp())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'pip.pep425tags' has no attribute 'get_abbr_imp'
This fails. So I tried :
$ python3.5 -c "import pip; print(pip.pep425tags.get_abbr_impl())"
cp
So I tried to update pip :
~$ pip install -U pip
Requirement already up-to-date: pip in /usr/local/lib/python3.4/dist-packages
I tried to follow the suggestions in Install pip for python 3.5 of L. Martin, but without success.
with pip3 the behavior is the same.
Could you tell me what when wrong, and how can I solve this?
Installing wxPython in Linux is not as straightforward as Windows/OSX wheels because there are too many variants: distro, GTK2/GTK3 etc. But they do explain how to install it in Linux:
https://wxpython.org/pages/downloads/
Installing with a downloaded wheel
You already found the correct wheel (cp35m-linux_x86_64) in wxPython Extras, but you must install it with the targeted Python version. If you can't find pip for your target Python, just use the -m option of Python:
python3.5 -m pip install wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl
Installing the usual way from pypi
The normal pip install method can work too, but for wxPython in Linux, that will try to build the wheel for you from the source archive - assuming you have all the dependencies. It will be inconvenient, and slow.
Again, you must run it with the correct targeted version of Python:
python3.5 -m pip install -U wxpython
Installing directly from wxpython.org wheels (recommended)
The easiest way is to get it directly from them:
python3.5 -m pip install wxPython -U --pre \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04
Or, if you just wanted to download the correct wheel to manually install later, and specifically wanted to target a specific python version, say 3.5:
pip download wxPython \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \
--only-binary=:all: \
--platform linux_x86_64 \
--abi cp35m \
--python-version 35 \
-d "${HOME}/pymodules/wxpython-py35-whl"
Change the distro in the url as needed. Note that the pip version is not important here.
The difference in 'm' and 'mu' is no longer relevant in Python 3. It was related to ucs2/ucs4 unicode build flags. If you were targeting Python 2.7 you would use the abi option to pick the 'mu' version like this: --abi cp27mu
Since pip 19.2 added a new debug command, these kinds of obscure issues may get easier to diagnose. That useless not a supported wheel on this platform message certainly didn't help anyone.

Dead Jupyter Kernel with python3

I am trying to use jupyter notebook with python3. Then I added the kernel with
python3 -m pip install ipykernel
python3 -m ipykernel install --user
But when I start a notebook it shows a Dead kernel message, and the terminal shows
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
If I choose python2 kernel it works well. I can run python command in console without any issue.
Try
python3 -m pip install --upgrade pip
python3 -m pip install jupyter
jupyter notebook
It worked for me.

How to install pip for Python 3.6 on Ubuntu 16.10?

I'd like to start by pointing out that this question may seem like a duplicate, but it isn't. All the questions I saw here were regarding pip for Python 3 and I'm talking about Python 3.6. The steps used back then don't work for Python 3.6.
I got a clear Ubuntu 16.10 image from the official docker store.
Run apt-get update
Run apt-get install python3.6
Run apt-get install python3-pip
Run pip3 install requests bs4
Run python3.6 script.py
Got ModuleNotFoundError below:
Traceback (most recent call last):
File "script.py", line 6, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Python's and pip's I have in the machine:
python3
python3.5
python3.5m
python3.6
python3m
python3-config
python3.5-config
python3.5m-config
python3.6m
python3m-config
pip
pip3
pip3.5
Let's suppose that you have a system running Ubuntu 16.04, 16.10, or 17.04, and you want Python 3.6 to be the default Python.
If you're using Ubuntu 16.04 LTS, you'll need to use a PPA:
sudo add-apt-repository ppa:jonathonf/python-3.6 # (only for 16.04 LTS)
Then, run the following (this works out-of-the-box on 16.10 and 17.04):
sudo apt update
sudo apt install python3.6
sudo apt install python3.6-dev
sudo apt install python3.6-venv
wget https://bootstrap.pypa.io/get-pip.py
sudo python3.6 get-pip.py
sudo ln -s /usr/bin/python3.6 /usr/local/bin/python3
sudo ln -s /usr/local/bin/pip /usr/local/bin/pip3
# Do this only if you want python3 to be the default Python
# instead of python2 (may be dangerous, esp. before 2020):
# sudo ln -s /usr/bin/python3.6 /usr/local/bin/python
When you have completed all of the above, each of the following shell commands should indicate Python 3.6.1 (or a more recent version of Python 3.6):
python --version # (this will reflect your choice, see above)
python3 --version
$(head -1 `which pip` | tail -c +3) --version
$(head -1 `which pip3` | tail -c +3) --version
In at least in ubuntu 16.10, the default python3 is python3.5. As such, all of the python3-X packages will be installed for python3.5 and not for python3.6.
You can verify this by checking the shebang of pip3:
$ head -n1 $(which pip3)
#!/usr/bin/python3
Fortunately, the pip installed by the python3-pip package is installed into the "shared" /usr/lib/python3/dist-packages such that python3.6 can also take advantage of it.
You can install packages for python3.6 by doing:
python3.6 -m pip install ...
For example:
$ python3.6 -m pip install requests
$ python3.6 -c 'import requests; print(requests.__file__)'
/usr/local/lib/python3.6/dist-packages/requests/__init__.py
This answer assumes that you have python3.6 installed. For python3.7, replace 3.6 with 3.7. For python3.8, replace 3.6 with 3.8, but it may also first require the python3.8-distutils package.
Installation with sudo
With regard to installing pip, using curl (instead of wget) avoids writing the file to disk.
curl https://bootstrap.pypa.io/get-pip.py | sudo -H python3.6
The -H flag is evidently necessary with sudo in order to prevent errors such as the following when installing pip for an updated python interpreter:
The directory '/home/someuser/.cache/pip/http' or its parent directory
is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory. If executing
pip with sudo, you may want sudo's -H flag.
The directory
'/home/someuser/.cache/pip' or its parent directory is not owned by the
current user and caching wheels has been disabled. check the
permissions and owner of that directory. If executing pip with sudo,
you may want sudo's -H flag.
Installation without sudo
curl https://bootstrap.pypa.io/get-pip.py | python3.6 - --user
This may sometimes give a warning such as:
WARNING: The script wheel is installed in '/home/ubuntu/.local/bin'
which is not on PATH. Consider adding this directory to PATH or, if
you prefer to suppress this warning, use --no-warn-script-location.
Verification
After this, pip, pip3, and pip3.6 can all be expected to point to the same target:
$ (pip -V && pip3 -V && pip3.6 -V) | uniq
pip 18.0 from /usr/local/lib/python3.6/dist-packages (python 3.6)
Of course you can alternatively use python3.6 -m pip as well.
$ python3.6 -m pip -V
pip 18.0 from /usr/local/lib/python3.6/dist-packages (python 3.6)
This website contains a much cleaner solution, it leaves pip intact as-well and one can easily switch between 3.5 and 3.6 and then whenever 3.7 is released.
http://ubuntuhandbook.org/index.php/2017/07/install-python-3-6-1-in-ubuntu-16-04-lts/
A short summary:
sudo apt-get install python python-pip python3 python3-pip
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
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
Then
$ pip -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ pip3 -V
pip 8.1.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
Then to select python 3.6 run
sudo update-alternatives --config python3
and select '2'. Then
$ pip3 -V
pip 8.1.1 from /usr/local/lib/python3.6/dist-packages (python 3.6)
To update pip select the desired version and
pip3 install --upgrade pip
$ pip3 -V
pip 9.0.1 from /usr/local/lib/python3.6/dist-packages (python 3.6)
Tested on Ubuntu 16.04.
Some of the solutions above using the script get-pip.py worked until a couple of weeks ago.
The latest version of this script now requires python3.7 throwing the following error
ERROR: This script does not work on Python 3.6
The minimun supported Python version is 3.7.
Please use https://bootstrap.pypa.io/pip/3.6/get-pip.py instead.
So making the corresponding change works now.
wget https://bootstrap.pypa.io/pip/3.6/get-pip.py
sudo python3.6 get-pip.py

Resources