Environment error when installing with pip - macos

I'm trying to install some python libraries with pip and I'm getting a repeated error when running it. For example, if I run pip install -U py2app the download appears to proceed as normally, but then an error is raised:
Could not install packages due to an EnviromentError
Which is followed by a series of [Errno 1] Operation not permitted errors (with directories listed after each error).
This error has appeared a number of times on several different libraries I've attempted to install, and it's extremely frustrating. I've tried to update the tools that people have recommended to update for various pip errors and none of them have made any difference.
Is there an easy fix to this problem?

Try to install using the option --user for example:
$ pip install --user py2app
Passing the --user option will install a package just for the current user, rather than for all users of the system.

Related

How to properly install prophet with python 3.9.13

The current pystan==2.19.1.1, and it seems that this's the highest version in python 3.9.
I have tried:
pip install prophet. Using this command I can install the prophet but when running fit I got errors. Error: Unexpected exception formatting exception. Falling back to standard exception.
pip install fbprophet. couldn't install it.
conda install -c "conda-forge/label/broken" prophet. Using this command I can install the prophet but when running fit I got errors again. Error: 'StanModel' object has no attribute 'fit_class'.
I have tried everything I can find online so far but still couldn't solve the problem, and unfortunately I can't change my python version cause I need this particular one to install keras and tensorflow in mac M1 system.

Devstack installation failed with error message "ERROR: Editable requirements are not allowed as constraints"

I encounter the following error when I run the script stack.sh:
Using python 3.6 to install setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,!=48.0.0,!=49.0.0
+ inc/python:pip_install:187 : sudo -H LC_ALL=en_US.UTF-8 http_proxy= https_proxy= no_proxy= PIP_FIND_LINKS= SETUPTOOLS_SYS_PATH_TECHNIQUE=rewrite python3.6 -m pip install -c /opt/stack/requirements/upper-constraints.txt --ignore-installed 'setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,!=48.0.0,!=49.0.0'
DEPRECATION: Constraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms. A possible replacement is replacing the constraint with a requirement.. You can find discussion regarding this at https://github.com/pypa/pip/issues/8210.
ERROR: Editable requirements are not allowed as constraints
++./stack.sh:main:752 err_trap
++./stack.sh:err_trap:530 local r=1
stack.sh failed: full log in /opt/stack/logs/stack.sh.log.2021-05-10-115040
Error on exit
And a little higher I have this warning:
Attempting uninstall: pip
Found existing installation: pip 21.1.1
Uninstalling pip-21.1.1:
Successfully uninstalled pip-21.1.1
Successfully installed pip-21.1.1
WARNING: Running pip as root will break packages and permissions. You
should install packages reliably by using venv:
https://pip.pypa.io/warnings/venv
Any idea why?
Thanks

How can I upgrade pip when there is a folder missing in the path it's trying to access?

I keep receiving the following message:
You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
However, when I try, I am met with this error:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/.umpy-1.15.4.dist-info/METADATA'
I had several errors exactly like this, and I noticed that METADATA was in the right place, but that there was an additional folder that was not included in the path above. I was able to get around this by moving METADATA out from the extra folder and into the folder listed in the error message above.
However, when I try to do that with this path, I notice the .umpy-1.15.4.dist-info directory does not even exist.
I struggling to understand if there's an easier way to accomplish this, or if I have messed up with my installation to being with.
first of all, before doing anything, always have a backup copy of pip which is generally in pythonxxx/Lib/site-packages
you can try below command
python3 -m pip install --upgrade pip
it will install updated pip and keep existing pip packages

pip install slackclient on OSX 10.11.1

My question is two-fold:
1) When I try pip install slackclient
I'm eventually thrown this error: error: could not create '/Library/Python/2.7/site-packages/websocket': Permission denied
To get around this I then tried: sudo pip install websocket which eventually throws this error: error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/greenlet': Operation not permitted
At this point I searched around a bit and found a cryptic page on github saying to do a pip install --user and that this error was the result of some issue with my version of OSX not allowing even root level access to some areas. I don't really follow this argument and so after little more information found on the web gave up on the error and didn't attempt the pip install --user.
What is the right thing to do here?
2) After reaching the last error in the above point, I gave up and tried sudo pip install slackclient and everything magically installed without errors.
Was this okay to do or will I regret this in some way down the road?
Thanks!

pip is not uninstalling packages

Background
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) python-twitter0.8.2 (http://pypi.python.org/pypi/python-twitter/0.8.2)
b) twitter1.9.1 (http://pypi.python.org/pypi/twitter/1.9.1)
(a) is called python-twitter in pypi, and (b) is called twitter, so that's how I'll refer to them.
Both of these are called by import twitter in the Python interpreter, but when I write that line, I always get the twitter one (if I can figure out how to use the python-twitter one, I'll be able to proceed, but will still have the same underlying problem).
Problem
Since I don't need the twitter package, I decided to uninstall it with pip:
$ sudo pip uninstall twitter
which gives the output:
Uninstalling twitter:
Proceed (y/n)? y
Successfully uninstalled twitter
(actually, I tried the same thing with python-twitter and got a similar response).
However, when running pip freeze, both of these packages show up on the installed list! In fact, I can still use the import twitter command successfully in the interpreter. Clearly the packages have not been uninstalled. What I would love to know is how to uninstall them!
Other Info
I'm using Python 2.7 and Ubuntu 12.04
When running IDLE instead of the shell interpreter, and I type help('modules'), neither twitter nor python-twitter shows up in the list. When typing help('modules') into the shell interpreter, I get a segmentation fault error, and the interpreter crashes. Here's the error:
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
from gtk import _gtk
** (python:2484): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register
existing type `GdkDevice'
from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata:
assertion `node != NULL' failed
from gtk import _gtk
Segmentation fault (core dumped)
Why other questions have not resolved this for me:
I looked at the similar post at pip freeze lists uninstalled packages and am not having the same issues.
$ sudo which pip
/usr/bin/pip
$ which pip
/usr/bin/pip
which is the same output. In addition, $ sudo pip freeze gives the same output as $ pip freeze.
Any help is very much appreciated!
You can always manually delete the packages; you can run:
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
to remove that package from your dist-packages directory. You may have to edit the easy-install.pth file in the same directory and remove the twitter entry from it.
While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
python-pip (1.0-1build1)
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain pip from upstream using the script get-pip.py you will have a fixed version of pip which can remove pacakges (as of now v. 1.5.6).
update
Python's pip is really a fast moving target. So using Debian's or Ubuntu's pip is guaranteed to have bugs. Please don't use those distribution's pip.
Instead install pip from upstream.
If you would like to register pip installed packages as system packages I really recommend that you also use stdeb.
I was facing difficulty while upgrading a package because pip was not able to uninstall it successfully. I had to delete the .egg-info and the folder as well in /usr/lib/python2.7/dist-packages and then I tried to install with --upgrade and it worked.
For me, it was due to the fact that I was running pip freeze, which gave me different results than sudo pip freeze.
Since I was uninstalling using sudo, it was not uninstalling it in the "non-sudo" session. Uninstalling without sudo fixed that.
In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working.

Resources