I run a pyenv to use python 3.5.2 and venv to manage my packages. I can successfully install the graph flower from github, but not the garden.matplotlib flower.
This command works fine:
.venv/bin/python3 -m pip install https://github.com/kivy-garden/graph/archive/master.zip
while this one downloads, but fails installation:
.venv/bin/python3 -m pip install https://github.com/kivy-garden/garden.matplotlib/archive/master.zip
How can I solve this? I need to develop the code on my Mac and run it on a raspberry pi afterwards.
pip 19.2.2 (for this environment)
The graph repo has the necessary code to be installable via pip, while the garden.matplotlib repo does not.
I think the matplotlib one may be waiting to be converted to a new-style garden flower, which is designed to be pip-installable.
A workaround would be to just copy the matplotlib one into your app dir and import from there.
Related
I am trying to install mmcv python package, but Ubuntu terminal crashes every time during installaction (application simply closes without any errors). I tried to install this package both using standard Linux terminal and via VS Code - the result is always the same. It causes no errors when I install other python packages, but when I try to install mmcv - terminal crushes.
I am using this code for installation:
pip install mmcv-full==1.3.9 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13.1/index.html
I tried to install mmcv using this code in Kaggle Kernel (it is Jupyter Notebook-like development environment, which works on Linux too) - and package was installed correctly.
It seems to me that my terminal crashes because mmcv is quite "heavy" python package, but I do not know what to do with it. How can I solve this problem and install mmcv?
It seems like my version of Ubuntu is not compatible with old versions of mmcv.
This code worked for me:
pip install -U openmim
mim install mmcv-full==1.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
I am trying to use pip to install libraries into a Python virtualenv, which resides on an AWS EMR master node. For some reason, sudo pip works fine, but non-sudo pip silently fails.
Some background:
I am launching an EMR cluster with version emr-5.19.0.
I am SSHing into the master node, which uses Amazon Linux AMI 2018.03.
By default, this OS has both Python 2.7 and 3.4 installed.
I created a new virtualenv, based on the already-installed Python 3.4.
I activated my new virtualenv, and verified that all paths point to my venv installation (not to the global Python installation), e.g. which python, which pip all look correct.
So, I create and activate my virtualenv as follows:
cd /home/ec2-user/my_app
virtualenv --python=python3.4 venv
source venv/bin/activate
This works. Next, I try to install a sample library as follows:
pip install numpy
The output is:
Collecting numpy
Installing collected packages: numpy
Successfully installed numpy-1.16.0
However, despite the output claiming success, import numpy produces an import error, and numpy doesn't show up in pip list or pip freeze. I have even drilled into path/to/venv/lib/python3.4/dist-packages and verified no numpy directory gets created.
Sadly, this does work:
sudo path/to/venv/bin/pip install numpy
The problem is: I don't want to use sudo, because that would defy best practices. However, it seems like most people are using sudo for this task (examples here and here), so perhaps this is just a requirement in an EMR environment?
Note: This issue only happens for some libraries. For instance, pyspark and geocoder install fine, but numpy and pandas silently fail.
I ended up figuring this out: pip was (sometimes, but not always) placing modules in a particular directory that wasn't on the Python path! This appears to be a known bug between Amazon Linux and pip.
For instance, numpy was getting placed at:
path/to/venv/lib/python3.4/dist-packages/numpy
However, pyspark was getting placed at:
path/to/venv/lib64/python3.4/dist-packages/pyspark
The latter directory is on the Python path, but the former was not. This is why import pyspark worked, but import numpy did not. We can force pip to install libraries into the appropriate directory as follows:
pip install numpy --target='/path/to/venv/lib/python3.4/dist-packages'
The command above solves my issue.
Edit: My question is not regarding how to immediately get pip to work. I fixed this by relinking as you can see in the question.
The question is: What is best/pythonic practice on a fresh *NIX system?
One would probably want to have the most recent version of both Python2 and especially Python3 with pip and setuptools and so on. A safeguarded virtual environment seems to be the way, but anyway one has to start somewhere.
So what is the recommendation?
From the comments it seems that one should use the get-pip.py script to install and then use pip to install virtualenv. I guess this has to be done both for Python2 and Python3 if one wants to have both.
This is what happened some days ago:
Ubuntu 18.04 and Python 2.7
I am a heavy R user, but use more and more Python. Virtually every time I set up any kind of customized python environment on Linux or OSX, something breaks and has to be fiddled with.... links, binaries, paths, dependencies. Each and every time. How many thousands of people are sitting on a Ubuntu/Debian box right now and do apt install python pip; pip install --upgrade pip and -duh- it breaks? Really?
Specifically right now: I want to install django on a webserver and started with apt install python-pip.
Then I did the recommended pip install --upgrade pip which installed pip-18.0 but gave the message Not uninstalling pip at /usr/lib/python2.7/dist-packages
After that pip --version threw an error
Traceback (most recent call last): File "/usr/bin/pip", line 9, in
from pip import main
It turned out that the old pip still resides in /usr/bin/pip while the new one is in /usr/local/bin/pip.
I fixed it brute force with:
rm /usr/bin/pip
ln -s /usr/local/bin/pip /usr/bin/pip
Did I do the right thing or is this the way to doom down the road?
Is there a pythonic or elegant way to handle such issues or to prevent them in the first place?
With best regards and thanks for any kind of suggestions.
My conclusion after investigating the hints in the comments is:
Python conflicts with itself.
Do not try to avoid this - cope with it.
Use virtual environments to handle the unavoidable multiple Python versions consistently.
pyenv seems to work best for my purposes. Use the following to install first pyenv (1), update it (2), install a Pythons version (for this example 3.5.6) with pyenv (3), set your user-global python to the installed version (4), upgrade the Python package mangement tools (5) and install anything inside the virtual Python enviroment (6).
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
pyenv update
CONFIGURE_OPTS=--enable-shared pyenv install 3.5.6
pyenv global 3.5.6
pip install --upgrade pip setuptools wheel
pip install ipython jupyter snowflake-connector-python seaborn
CONFIGURE_OPTS=--enable-shared in (3) is needed for some python packages which depend on shared libraries. seaborn will not install without it.
Note that the pyenvinstalled versions includes the package manager pip. Now every call python or pip everything references to the correct version.
When referencing python in scripts in MacOS bash and other *NIXes use #!/usr/bin/env python.
It is possible to install pyenv install 2.7.15 the latest python 2.7 and change to it whenever necessary. pyenv shell 2.7.15 switches to Python2.7 only for a particular shell session when needed to run an adhoc script.
Since I use this flow I have no headaches anymore.
The same setup works superfine so far both on a local MacOS and on a remote Ububtu based jupyter notebook server.
Disclaimer: I am not a hardcore Python fullstack developer, but use Python whenever necessary in Data Science pipelines. So for application development in Python this might not be the best solution, but for consistent management of a Data Science environment it seems to work well.
Hope this is helpful.
I have changed my computer to a Linux Mint x64 OS and I have throubles with a python library, igraph library, when i try to execute and old program I made.
DeprecationWarning: To avoid name collision with the igraph project, this visualization library has been renamed to 'jgraph'. Please upgrade when convenient.
I can't find information about how to change my code for the new library.
On a Win8 PC, via pip installation, it works perfectly but I can't make it working on my PC with Mint.
The normal installation made with
sudo apt-get install python-igraph
install 0.6.5-1 library version.
I've also tried installing it with pip but it gives me same error
but installed version is igraph-0.1.11-py2.py3-none-any.whl
I'm using only Graph class
from igraph import Graph
What have I to do to change my code to make it working with the new library? Am I missing something?
edit: it's working on my laptop with Mint x86 OS, library version 0.6.5-1
I think you have installed the wrong igraph libray.
This igraph(0.1.11) is the one you installed, while this igraph(0.7.1) is the one you need (and the well-known iGraph).
Using pip (once you've installed it), Just do:
sudo pip uninstall igraph
Then install the python-igraph-0.7.1 package, using either pip or apt-get as mentionned in comments below:
sudo pip install python-igraph
Hope it works.
sudo -H pip uninstall igraph
then:
sudo pip install python-igraph
worked for me.
So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows?
Thanks
It's on PyPI. As of wxPython 4, Python 3 is supported.
Unfortunately, PyPI has a package called wx that is stuck at version 3.0.3; be sure to install the package named wxpython instead.
pip install wxpython
Please note that pip will automatically build wxWidgets for you, but it will not install wxWidgets system dependencies such as GTK and OpenGLu. If the above command exits with an error, look above for a message like this:
checking for <something>... not found
checking for <something>... no
configure: error: <prereq> libraries not available
Error running configure
ERROR: failed building widgets
This should give you information about at least one of the packages your system is missing.
The "official" list of prerequisites from the wxWidgets source is:
dpkg-dev
build-essential
libjpeg-dev
libtiff-dev
libsdl1.2-dev
libgstreamer-plugins-base0.10-dev # or 1.0 if available
libnotify-dev
freeglut3
freeglut3-dev
libsm-dev
libgtk-3-dev
libwebkitgtk-3.0-dev # or libwebkit2gtk-4.0-dev if available
libxtst-dev
The actual package names provided by your package manager may not match these exactly, and to be honest, I don't really know the best way to query a package manager to determine what packages provide the libraries you need.
3 steps to install wx-widgets and pygame in python IDLE
Install python 3xxx in your system opting (Add 3xxx to your path).
open python CLI to see whether python is working or not.
then open command prompt (CMD).
type PIP to see whether pip is installed or not.
enter command : pip install wheel
enter command : pip install pygame
To install wxpython
enter command : pip install -U wxPython
Thats all !!
As per home page instruction:
Make sure you have at least version 6.0.8 of pip and 12.0.5 for setuptools.
Install requirements for Linux as outlined in the readme.rst at:
https://github.com/wxWidgets/Phoenix/blob/master/README.rst
Install wxPython-Phoenix (Linux):
sudo pip install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
Install wxPython-Phoenix (Windows, use the appropriate script folder):
C:\python27\scripts\pip.exe install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
I installed wxPython as part of the PsychoPy experiment builder dependencies, and had considerable trouble getting it to install properly as well initially. But this was what worked for me at the end. I use Ubuntu 16.04, python 3.5, pip3 19.0.3
pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython --user
If you use Conda then you may easily setup the environment with wx by one line:
$ conda create -n wxenv python=3 wxPython
Solving environment: done
## Package Plan ##
environment location: /home/user/.conda/envs/wxenv
added / updated specs:
- python=3
- wxpython
The following packages will be downloaded:
package | build
---------------------------|-----------------
[...]
Proceed ([y]/n)?
You need to ensure the versions of your wxPython download matches your installed python language library.
The current downloads wxPython downloads doesn't show any libraries built against python 3. I Believe the python 3 porting project is still ongoing.
If you are not sure of what you are doing I would stick with the 32bit version on windows as there are some Python libraries (ie IIRC, MySQLdb) which don't work with 64 bit python.
So you would then need to download python2.7 for windows x86 and "wxPython3.0-win32-py27 32-bit Python 2.7"
To install wxPython GUI library correctly go to the following page (https://wxpython.org/Phoenix/snapshot-builds/), which contains snapshots builds of wxPython library (Phoenix version) depending on your os and version of Python you want to work.
Then when you downloaded the proper package for your system and python version, simply install it by using pip. In my case I've choosen that one (wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl):
pip install wxPython_Phoenix-3.0.3.dev2811+ecc4797-cp36-cp36m-win_amd64.whl
To check that it has been installed sucessfully on the site-packages folder for your current python environment write:
pip freeze
It's all!
Check the version of wxpython and the version of python you have in your machine.
For python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package
The problem was solved in openSuse simply with
zypper in python-wxWidgets-3_0-devel
Trying pip install before, gave me a lot of trouble (missing traits, missing wx/setup.h, https://github.com/wxWidgets/Phoenix/issues/1644, error: aggregate ‘wxGLAttributes _NullGLAttributes’ has incomplete type and cannot be defined, etc.).
wxpython failed to be installed with pipenv. Pipenv is not able to find wxpython binary so it tries to build wxpython but fails.
CXXFLAGS="-I/opt/homebrew/include" pipenv install wxpython
On my macOS M1 pipenv failed to install wxPython. After a lot of searching I found a forum post which really helped me fix the problem.
Source/Credits: https://forums.wxwidgets.org/viewtopic.php?t=47953&p=203709
Install current development version with:
pip install -U https://github.com/robotframework/RIDE/archive/master.zip
(python < 3.9) Install current Beta version (2.0b1) with:
pip install psutil
pip install -U --pre robotframework-ride
Note that I tried to install wxPython with 'pip install -U wxPython' as per instruction
with no avail. Too many errors to list here. 🤨
I found a solution to the problem!!
I'm working on a 64b machine and Windows 11 operating system using VSCode.
Here is the solution using PowerShell:
Version specs:
pip 22.3.1
virtualenv 20.15.1
python 3.10.8
Create a new virtual environment in the directory where the program resides and
activate. There must be no modules installed.
virtualenv venv
venv/scripts/activate.bat
Install the following in sequence:
pip install pygame
(Not sure why pygame must be installed first, but this was
recommended and it works) 😟
pip install -U wxPython
SUCCESS!!! 🤠
These are the modules installed:
numpy 1.24.1
Pillow 9.4.0
pip 22.3.1
pygame 2.1.2
setuptools 65.4.0
six 1.16.0
wheel 0.37.1
wxPython 4.2.0
VSCode still reports wx as a missing module even when you activate the virtual
environment within. Running the code from the PS command prompt within the virtual
environment is the only working solution.
PS. I am sure there are some conflicts when trying to install wxPython within an
environment where all the other modules are installed.