permission denied when installing python packages through cygwin - python

I'm working on a windows 7 and using Cygwin for unix-like functionality. I can write and run Python scripts fine from the Cygwin console, and the installation of Python packages using pip installis successful and the installed package appears under pip list. However, if I try to run a script that imports these packages, for example the 'aloe' package, I get the error "no such module named 'aloe'".
I have discovered that the packages are being installed to c:\python27\lib\site-packages, i.e. the computer's general list of python packages, and not to /usr/lib/python3.6/site-packages, i.e. the list of python packages available within Cygwin. I don't know how to rectify this though. If I try to specify the install location using easy_install-3.6 aloe I get the error
[Errno 13] Permission denied: '/usr/lib/python3.6/site-packages/test-easy-install-7592.write-test'.
In desperation also tried directly copying the 'aloe' directory to the Cygwin Python packages directory using cmd with cp -r \python27\lib\site-packages\aloe \cygwin\lib\python3.6\site-packages and the move was successful, but the problem persists and when I check in the Cygwin console using ls /usr/lib/python3.6/site-packages I can't see 'aloe'.
I have admin rights to the computer in general (sudo is not available in Cygwin anyway) so really can't figure out what the problem is. Any help would be greatly appreciated.
Thanks.

just make sure you are in admin mode.
i.e. right click on Cygwin, select running as administrator.
then install your package specifically using pip3, for python3.
i.e. pip3 install your_package
with updated version, do pip3 install --upgrade your_package

Related

What is the difference between installing a package in my Windows CMD and in VS Code terminal?

I am doing this project where i need to install a package called Twint.
I want to install this package and use it's commands in my VS Code.
What happends when i for example type this in my Windows CMD?
pip3 install --user --upgrade git+https://github.com/twintproject/twint.git#origin/master#egg=twint
Because i can't type this in my VS code terminal, where i usually install packages with pip.
It will return an error that says ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?''
Now if i run this in my Windows Command it seems that i can't directly import the package in VS code?
Can anyone help me out with this confusion, where does the files get stored and how do i create good habbits around installing packages?
Hope someone understands what im struggeling with here.
Best
It is often the case that computers have more than one version of python installed and that editors like VS code use a different version than pip uses on the command line. pip installs packages where the version of python it is linked to expects them to be, but VScode doesn't know to look there.
It sounds like you have git installed where pip installs things, so you can upgrade from the command line without issue, but there's no installation of git where VScode is looking, so there's nothing to upgrade.
You either need to find where pip installs things and add it to the $PATH VScode uses, or try running a variation of python -m pip install --user git (specifying a specific url, or other things, as needed) from within VScode, which will ensure the package gets installed in a place that VScode looks for packages.
Download and Install git in your windows from here:
https://git-scm.com/download/win
Then add its installation bin path to your windows's environment path. Then you will find the git command at the command prompt globally.
This may solve you problem.

Permission error [Errno13]Permission denied while installing robotframework-SikuliLibrary

I have a Linux machine with Ubuntu rel 20.10, I'm using the robot framework with Eclipse. I have a problem with a Sikulilibrary
doesnt'work. I tried to pip install robotframework-SikuliLibrary,
But i have this error
> Exception : Initializing test library Sikulilibrary with no arguments
> failed:Permission error[Errno13]Permission denied
I tried to install Selenium library all is ok,do you have any questions about this issue?
Robotframework 3.2
Python 3.8.6
Thanks a lot
pip wants to install the package in your system, and you don't have the right to write here. But... Do NOT use sudo with pip. This will install system-wide and can break your installation or a package can overwrite this one.
Use virtualenv, or pipenv.
E.g. To use virtualenv:
cd your-project
python -mvenv .venv
source .venv/bin/activate
# and then
pip install XXX
You will need to call source .venv/bin/activate anytime you want to work and launch your project. The behavior is to change the installation path to a local path (and not your system).
Or, like said #BIOS in https://stackoverflow.com/a/66785567/1472048 comment, use your "home" installation with "--user" option to install in ~/.local/lib.
Make sure that you are adding the module in the correct Python installation (your Python 3.8 and not the system Python) and that you are installing in your home directory. This way no special permission will be needed.
pip3 install --user robotframework-SikuliLibrary
The above will install the package in the user site-packages directory of the current (running) Python. In my case it is ~/.local/lib/Python3.9/site-packages, which is already in my PATH. It should be the case for you too, so you should be good to go.
Otherwise, if you have problems like ModuleNotFoundError just find your site-packages directory with:
python3 -m site
You will have it under USER_SITE. Take note of it and add it to PATH following help from this question.
Otherwise, like #Metal3D said, you could use a virtual environment

Installing pyobjc on a Mac

I am facing problems installing pyobjc on my mac.
Basically I have to install pyobjc on a new Mac System in the system default python. I have so far tried easy_install, pip and downloading the pkg file and installing. All give me a error in different ways. Some give me a error saying certain safari files are missing other cant due to some permission being denied even though I am running them through sudo su.
I then found a fix.
pip install pyobjc --user
This worked and I could access all the modules I required, but then if I try running python through sudo, I cant access those modules.
Can anyone suggest a fix for this.
NOTE: I don't mind a different method to install also. Also I have not tried brew due to some previous difficulties with it.
NOTE 2: I need to be able to access those modules using all users on the computer, the root user and me(the non-root user)
i had to (temporarily) move (using sudo) /Library/Python/2.7/site-packages/Extras.pth to another name before I could install the current pyobjc.
This is what works for me:
sudo mv /Library/Python/2.7/site-packages/Extras.pth /Library/Python/2.7/site-packages/Extras.pth_orig
pip install --upgrade pyobjc
sudo mv /Library/Python/2.7/site-packages/Extras.pth_orig /Library/Python/2.7/site-packages/Extras.pth
It appears that something in the .pth file interferes with the install, but does not impede running pyobjc.
but then if I try running python through sudo, I cant access those
modules.
Because sudo python basically means run python as some other user (root by default). That user may have a different set of environment variables, including $PATH.
Some of linux distributions use older Python version for root user,like centos.If the Python verison you're running with sudo isn't correct,you can't access those modules installed by pip.
So in my opinion,if you didn't get permission issues,you don't need to use sudo ,using sudo might bring unexpected mistakes(most environment variables issues),maybe chown or chmod can fix those issues.
So here are my plans:
Plan A: The best way is to try to use virtualenv.
Plan B: Install modules without sudo command,if got permission errors(not very common),try --user .
Install to the Python user install directory for your platform.
Typically ~/.local/, or %APPDATA%Python on Windows.
In most cases,you should modify your PYTHONPATH.See details from How do I access packages installed by pip --user.
Plan C: All related commands are executed with sudo.sudo pip install (all modules) and sudo python script.py.Not a good idea.

Pip.exe from Python on Windows 10

I installed the latest version of Python from www.python.org. Python 3.4.3. I then go to run pip and I get
"Fatal error in launcher: Job information querying failed"
Searching for this error message points me to similar issues running Python under wine. If you grab a pre-compiled pip.exe it will work but it seems that when you install, the pip.exe is generated as part of the installer and this pip.exe does not work.
Further I am dealing with a build script that creates a virtual python environment that uses pip.exe and results in the same error. Not sure how to fix this. Also not sure how pip.exe is generated.
You can use python -m pip install package
Worked for me in windows 10, make sure that you have added python in path of system environment variable. If you are able to run python from powershell then it means python is added to your path. After that you may try using following to upgrade pip
python -m pip install -U pip

pip/easy_install failure: failed to create process

After following this article: How do I install pip on Windows? on my Windows system using Enthought Canopy 64 Bit system, I cannot get pip or easy_install to work due to error:
pip install requests
failed to create process
I tried re-installing setuptools, running cmd prompt as admin without any effect.
When I encountered this, it was because I'd manually renamed the directory python was in. This meant that both setuptools and pip had to be reinstalled. Or, I had to manually rename the python directory to what it had been previously.
It will help after changing the PATH to python in environment variables:
python -m pip install --upgrade pip --force-reinstall
Just ran into this. Sort of. Pip worked for me, but after installing pytest-watch, running the ptw script was giving this error.
For some reason, pip stopped quoting the #! in ptw-script.py:
#!C:\Program Files (x86)\Python\python.exe
It worked after I added quotes manually:
#!"C:\Program Files (x86)\Python\python.exe"
I don't really know why this suddenly started happening. Adding this here in case anyone else coming here from Google runs into the same thing.
Here's a related pip issue (I think).
If you intentionally want to rename the folder where python.exe resides, you should also modify all python files in the Scripts folder. So a third solution would be to modify the python files as well: the first line in pip-2.7-script.py originally contain:
#!C:\OriginalPythonDir\python.exe
Modifying this path to the new Python folder fixes the problem.
(P.S. Unfortunately I cannot yet reply to answers, so I'll reply as a new answer because I thought it could be useful for other people as well).
To fix this error (after you change the folder where python is installed) run force-reinstall for pip and pyinstaller, like this:
python -m pip install --upgrade pip --force-reinstall
python -m pip install --upgrade pyinstaller --force-reinstall
I ran into this bug while installing an older version of Python (3.5.2) for compatibility with some aws-adfs scripting. I installed aws-adfs with pip, on Windows 10, and found that while Python is installed to a directory path with spaces in it you will get the failed to create process error.
The pip maintainers say that it was a deeper problem with setuptools and even offered a workaround if you want to patch the installation in place.
But another, easier solution if you're working with older versions of Python is just to reinstall Python to a directory without spaces.
When I came across this problem, I found that my path contained multiple entries for Python. After tidying up my path so that it had an entry for the python installation folder and the scripts folder (in my case C:\Python27 and C:\Python27\Scripts), pip worked properly.
Test this. it's worked correctly for me:
python -m pip install --upgrade pip --force-reinstall
I just use python in the command shell on Windows 7 and had this problem immediately after installing pip. In case the above solutions don't help you, you should check that the folder that pip.exe is installed in (in my case, the Script folder under Python32) is in the Path.
I had installed Anaconda and so I still had C:\Python27 along with C:\Anaconda in my path. When I removed C:\Python27 and all subfolders I was able to use pip again.
Please check out have you ever rename your python.exe
I install python2 and python3 on my PC at the same time , so I rename my python.exe to python3.exe.And when I use pip ,it boom...
After rename it back .It's ok again....
Running command prompt with administrator privileges worked for me.
I had the same problem and none of the above worked for me.
I deleted my venv. And created a new one by specifying the python path:
virtualenv --python C:\Path\To\Python\python.exe venv
.\venv\Scripts\activate
and this worked
Check whether the pip-script points out the exact location of python.exe, because pip always points (C:\python3.3\python.exe). In my system i've installed 2 versions of python i.e python2 & python3. I ve modified the home application of python.exe into python2.exe and python3.exe.
When i installed pip windows installer. it results me out with the error " failed to create process"

Categories