installing Mayavi with pip - no module named 'vtkOpenGLKitPython' - vtk

I am trying to install mayavi via pip on my ubuntu 16.04 via shell. I am using python 3.6 via anaconda and already installed vtk and all other requirements but i get the above error when i try pip3 install mayavi or pip2 install mayavi.

Mayavi is packaged for ubuntu packages.ubuntu.com/xenial/mayavi2.
I suggest that you install with the command
sudo apt-get install mayavi2
instead, this will take care of installing a version that matches the vtk install on your system.

Try to rename libvtkOpenGLKitPython*.so file.
In my case it was:
cd /opt/conda/envs/pytorch-py3.6/lib/python3.6/site-packages/vtk
cp libvtkOpenGLKitPython36D-8.1.so libvtkOpenGLKitPython.so
and, maybe one more error with libxt6 file. Fix it:
apt install libxt6

Related

Error installing psycopg2 on macOS with building wheel [duplicate]

I'm attempting to make a website with a few others for the first time, and have run into a weird error when trying to use Django/Python/VirtualEnv. I've found solutions to this problem for other operating systems, such as Ubuntu, but can't find any good solutions for Mac.
This is the relevant code being run:
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
After running that block, I get the following errors:
AssertionError
Failed building wheel for django-toolbelt
Running setup.py bdist_wheel for psycopg2
...
AssertionError
Failed building wheel for psycopg2
Failed to build django-toolbelt psycopg2
I believe I've installed the "django-toolbelt" and "psycopg2", so I'm not sure why it would be failing.
The only difference I can think of is that I did not use the command
sudo apt-get install libpq-dev
as was instructed for Ubuntu usage as I believe that installing postgresql with brew took care of the header.
Thanks for any help or insight!
For MacOS users
After trying all the above methods (which did not work for me on MacOS 10.14), that one worked :
Install openssl with brew install openssl if you don't have it already.
add openssl path to LIBRARY_PATH :
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
install psycopg2 with pip pip3 install psycopg2
I had the same problem on Arch linux. I think that it's not an OS dependant problem. Anyway, I fixed this by finding the outdated packages and updating then.
pip uninstall psycopg2
pip list --outdated
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
I was also getting same error.
Using Python 3.7.3 and pip 19.1.1.
I used following command.
pip install psycopg2-binary==2.8.3
TDLR
If you aren't used to installing Python C-extensions, and psycopg2 isn't a core part of your work, try
pip install psycopg2-binary
Building Locally
psycopg2 is a C-extension, so it requires compilation when being installed by pip. The Build Prerequisites section of the docs explain what must be done to make installation via pip possible. In summary (for psycopg 2.8.5):
a C compiler must be installed on the machine
the Python header files must be installed
the libpq header files must be installed
the pg_config program must be installed (it usually comes with the libpq headers) and on $PATH.
With these prerequisites satisfied, pip install psycopg2 ought to succeed.
Installing pre-compiled wheels
Alternatively, pip can install pre-compiled binaries so that compilation (and the associated setup) is not required. They can be installed like this:
pip install psycopg2-binary
The docs note that
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements.
but I would suggest that psycopg2-binary is often good enough for local development work if you are not using psycopg2 directly, but just as a dependency.
Concluding advice
Read the informative installation documentation, not only to overcome installation issues but also to understand the impact of using the pre-compiled binaries in some scenarios.
I had same problem and this appears to be a Mojave Issue, I was able to resolve with:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
For Mac OS X users:
1. First check your postgresql path by running this command in terminal:
pg_config
If this fails lookup how to add pg_config to your path.
2. Next install Xcode Tools by running this command in terminal:
xcode-select --install
If you have both those sorted out now try to install psycopg2 again
For MacOS users, this question has the correct solution:
install command line tools if necessary:
xcode-select --install
then
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2
I was also facing the same after running all the above commands, but the following two commands worked for me:
Instead of pip, use this:
sudo apt-get install libpq-dev
then run this command:
pip install psycopg2
On OS X, I was able to solve this by simply upgrading wheel before installing psycopg2:
pip install --upgrade wheel
For OSX Sierra users, it seems that an xcode update is the solution: Can't install psycopg2 package through pip install... Is this because of Sierra?
I tried all the above solutions but they did not work for me. What I did was change the psycopg2 version in my requirements.txt file from psycopg2==2.7.4 to psycopg2==2.7.6
Is your error message complete? the most encountered reason for failing to install psycopg2 on mac from pip is pg_config is not in path.
by the way, using macports or fink to install psycopg2 is more recommended way, so you don't have to worry about pg_config, libpq-dev and python-dev.
plus, are using Python 3.5? then upgrage your wheel to > 0.25.0 using pip.
I faced the same issue, but the answers above didn't work for me.
So this is what I did in my requirements.txt
psycopg2-binary==2.7.6.1 and it worked fine
I had this issue on several packages, including psycopg2, numpy, and pandas. I simply removed the version from the requirements.txt file, and it worked.
So instead of psycopg2-binary==2.7.6.1 I just had psycopg2-binary.
I know you are asking for development environment but if you are deploying on server say, Heroku. Just add below line in the requirements.txt of your project.
django-heroku==0.3.1
As this package itself will install the required packages like psycopg2 on server deployment.So let the server(heroku) should take care of it.
sudo apt install libpq-dev python3.X-dev
where X is the sub version,
these should be followed by :
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
Enjoy !!!
I solved my problem by updating/installing vs_BuildTools. The link to the software was given in the error itself.
Error Image
Fixed by installing python3.7-dev: sudo apt install python3.7-dev, based on the link.
Python: 3.7
Ubuntu: 20.04.3 LTS

Docker python unable to import module installed via apt-get

I'm trying to build a python app via docker, but it fails to import numpy even though I've installed the appropriate package via apt. As an example of the dockerfile reduced to only what's important here:
FROM python:3
RUN apt-get update \
&& apt-get install python3-numpy -y
RUN python3 -c "import numpy; print(numpy.__version__)"
Attempting to build that dockerfile results in the error ModuleNotFoundError: No module named 'numpy'.
I am able to get this working if I use pip to install numpy, but I was hoping to get it working with the apt-get package instead. Why isn't this working the way I would expect it to?
The problem is that you have two Pythons installed:
The image comes with python in /usr/local/bin.
When you install python3-numpy, that install python3 package from Debian, which ends up with /usr/bin/python.
When you run your code at the end you're likely using the version from /usr/local/bin, but NumPy was installed for the version in /usr/bin.
Solution: Install NumPy using pip, e.g. pip install numpy, instead of using apt.
Long version, with other ways you can get import errors: https://pythonspeed.com/articles/importerror-docker/
The problem is with python environments, not with docker. The apt-get installed numpy is not in the same environment as the python installation. Moreover, the dependencies should be stored in a requirements.txt file, which should then be installed through pip. python -m pip can be used to ensure that the pip command is in the same environment as the python installation.

Install pybox2d for python 3.6 with conda 4.3.21

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.

Issue installing shapely Python Package

I am running python 3.6 on windows and am attempting to install Shapely using
pip install shapely==1.6b2
It is giving me the following errors
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Cameron\AppData\Local\Temp\pip-build-242ae_ih\shapely\
I have seen the other posts about this issue and have tried:
pip install --upgrade setuptools
pip install ez_setup
easy_install -U setuptools
Nothing seems to work and I am not sure what to do next. Any advice would be appreciated.
Thanks
You may try to use the binary from this unofficial site. Just use pip install {wheel file name} to install it.
Shapely‑1.5.17‑cp36‑cp36m‑win32.whl (32-bit)
Shapely‑1.5.17‑cp36‑cp36m‑win_amd64.whl (64-bit)
Hope this would make the installation easier.
I had a similar error for installing shapely-1.5.17 via pip install shapely, and installing this made the pip install command work thereafter:
sudo apt-get install libgeos-dev
As of 2020, you can now simply install Shapely for Windows with:
pip install shapely
(you many need --upgrade to get at least version 1.7.0, when binary wheels were added for Windows)

how to install turtle with python3 on linux

when I install turtle,meet some problem like this :
My python version is 3.5.2 and OS is Ubuntu 16.04 LTS
apt install python3-tk
It is tested and works perfectly on Linux Mint and Ubuntu...
Edit:
The reason is because turtle is based on tkinter, for example:
I assume you ask for Turtle to draw forward, left, etc.
It is already installed with Python. You don't have to install it. Probably You may have to install python3-tk using pip3 install python3-tk or rather apt install python3-tk
See
pip search turtle
part of result
turtle (0.0.2) - Turtle is an HTTP proxy whose purpose is to throttle connections to
specific hostnames to avoid breaking terms of usage of those API
providers (like del.icio.us, technorati and so on).
You try to install some HTTP proxy
except ValueError, ve: is correct syntax in Python 2 but not in Python 3.
I was am using Ubuntu 18.10 and recently after configuring Python 3 as my default environment I got the same error.
I used this command to reconfigure it and it worked.
sudo apt install python3-tk
Success!!
pip install python-tk
then go to python shell and type
from turtle import*
fd(100)
I have had the same error but on Mac os and I tried to update my python via brew. This fixed my problem.
Firstly, give brew permission to access your shared files,
sudo chown -R $(whoiam) /usr/local/share
This was for another problem with brew :D, you can test the next command and use this only if you need to.
Finally,
brew upgrade python3
this worked for me. I am using Pop Os 22.04. Type these commands on the terminal. Hope this will for for you as well.
To install the current version of Python3:
sudo apt-get install python3
To install the pip package manager:
sudo apt install python3-pip
Run the below command in the terminal to install the Turtle library
sudo pip3 install PythonTurtle
To verify the installation:
python3 -m pip show PythonTurtle

Resources