Python packages installing error in deep-learning environment - python

When I am installing the new package in my deep-learning environment it gives me this error:
Could not install packages due to an EnvironmentError: [WinError 32]
The process cannot access the file because it is being used by another
process: Consider using the --user option or check the permissions.
Please help to resolve this

You are trying to install the package to a system folder which you don't have permissions to write to.
You have three options(use only one of them):
1-setup a virtual env to install the package (recommended):
python3 -m venv env
source ./env/bin/activate
then:
Install your package using python -m pip install <name_package>
2-Install the package to the user folder:
Install your package using:
` python -m pip install --user <name_package>
3-use sudo to install to the system folder (not recommended):
`sudo python -m pip install <name_package>

terminal one as administrator if using Windows and use ubuntu before command use sudo.

Related

Command "python3 -m pip install [...]" failed with error code 1 in None

I am trying to install the PyInstaller module for python through the terminal on my mac, and it is not working.
I am trying to install this module so I can package a program. I have tried to install through terminal through different commands (e.g. "pip install pyinstaller), but it is not working, even though I know I have PIP correctly installed.
When trying to install, I type, python3 -m pip install pyinstaller.
The result is Command "/usr/local/bin/python3 -m pip install --ignore-installed --no-user --prefix /private/var/folders/w5/rlzrygt57j3c3nl4p29d2djc0000gw/T/pip-build-env-mjrd7sir https://files.pythonhosted.org/packages/b2/86/095d2f7829badc207c893dd4ac767e871f6cd547145df797ea26baea4e2e/setuptools-41.2.0-py2.py3-none-any.whl#sha256=4380abcf2a4ffd1a5ba22d687c6d690dce83b2b51c70e9c6d09f7e8c7e8040dc https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl#sha256=f4da1763d3becf2e2cd92a14a7c920f0f00eca30fdde9ea992c836685b9faf28" failed with error code 1 in None
I have upgraded PIP, and tried using sudo python3 -m pip install pyinstaller, but I am not in the sudoers file.
Please help
Create a virtual environment for your project in your project directory.
python3 -m venv env
source env/bin/activate
Test which python is activated
which python
This will show that your local python in the virtualenv you just created is now the current python
Try installing now using
pip install pyinstaller
This ought to work for you. Always use virtual environments for your projects instead of installing system wide libraries unless you really need to set this up for the system.

How to fix error when downloading pyPDF2 on Python 3.6.0?

I am trying to install the pyPDF2 package on Python 3.6.0. When I open the Command Prompt and type python -m pip install pyPDF2 I receive the following error:
Successfully built pyPDF2
Installing collected packages: pyPDF2
ERROR: Could not install packages due to an EnvironmentError:
[WinError 5] Access is denied: 'C:\Program
Files\Python36\Lib\site-packages\PyPDF2' Consider using the
--user option or check the permissions.
Previously, I experienced a similar issue with installing the pip library. I had to receive administrative rights from another user before successfully downloading pip.
I am using Windows 10 OS.
There are a number of options:
Install packages in your user directory using pip --user (answer of PoorProgrammer)
This is also the solution provided in the error message itself, and should always work.
Run the python/pip as administrator (answer of Sıddık Açıl)
This is only useful if you have administrative rights.
Install Python in a non-protected directory (e.g. C:\Python\3.6) instead of in C:\Program Files.
This should work as long as you're allowed to install software on the computer. Once installed, you can install additional packages without administrative rights.
Install packages in a virtual environment.
This also works without administrative rights, but you need to install virtualenv once first (e.g. using python -m pip install --users virtualenv).
To create a virtual environment for Python 3.6 and install the package in it:
py -3.6 -m virtualenv --python=3.6 my_virtual_environent
my_virtual_environent\Scripts\activate
python -m pip install pyPDF2
You can install it locally on your user as well. I assume that you don't want to have to go and get your cmd elevated every time so the following should work:
python -m pip install --user pyPDF2
If you want to see the location, it should be at %APPDATA%\Python since you are using windows.
Open cmd as an administrator to get elevated access and run your Python pip install script again.

Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

I am trying to install numpy on macOS X but after executing the command pip install numpy I am getting the error:
Environment error :[error 13]: permission denied : 'usr/local/bin/f2py
How do I fix it?
This worked for me.
pip3 install --user package-name # for Python3
pip install --user package-name # for Python2
The --user flag tells Python to install in the user home directory. By default it will go to system locations. credit
pip install --user package-name
Seems to work, but the package is install the the path of user. such as :
"c:\users\***\appdata\local\temp\pip-req-tracker-_akmzo\42a6c7d627641b148564ff35597ec30fd5543aa1cf6e41118b98d7a3"
I want to install the package in python folder such c:\Python27. I install the module into the expected folder by:
pip install package-name --no-cache-dir
I am also a Windows user. And I have installed Python 3.7 and when I try to install any package it throws the same error that you are getting.
Try this out. This worked for me.
python -m pip install numpy
And whenever you install new package just write
python -m pip install <package_name>
Hope this is helpful.
I too had to face the same problem. This worked for me. Right click and run as admin than run usual command to install. But first run update command to update the pip
python -m pip install --upgrade pip
Well, in my case the problem had a different cause, the Windows path Length Check this.
I was installing a library on a virtualenv which made the path get longer. As the library was installed, it created some files under site-packages. This made the path exceed Windows limit throwing this error.
Hope it helps someone =)
As a windows user, run an Admin powershell and launch :
python -m pip install --upgrade pip
I just ran the command with sudo:
sudo pip install numpy
Bear in mind that you will be asked for the user's password.
This was tested on macOS High Sierra (10.13)
I had the same problem for different package. I was installing pyinstaller in conda on Mac Mojave. I did
conda create --name ai37 python=3.7
conda activate ai37
I got the mentioned error when I tried to install pyinstaller using
pip install pyinstaller
I was able to install the pyinstaller with the following command
conda install -c conda-forge pyinstaller
If you are already using an virtual env on ubuntu and if you get this error,then navigate to your virtual env folder.If you see a lock symbol like:
Then you don't have the appropriate permission as a user to pip install inside this.Hence change the permission of the venv folder using this command:
sudo chown -R $USER path/to/venv
Now switch to the venv and install your package.
On Windows this has worked for me. From the command line, specify the path to the exe for Python:
& "C:/Program Files (x86)/Python37-32/python.exe" -m pip install --upgrade pip --user
It is always preferred to use a virtual environment ,Create your virtual environment using :
python -m venv <name_of_virtualenv>
go to your environment directory and activate your environment using below command on windows:
env_name\Scripts\activate.bat
then simply use
pip install package_name

Python packages installing in the wrong folder

I am attempting to use Anaconda and running into issues with packages installing in the wrong folders (because I have multiple versions of python installed, which cannot be removed). How do I correctly get new packages installing to the anaconda3 python version?
For example:
pip3 install praw <-- installs to python2.7 folder
$ python -m site --user-site
/home/king/.local/lib/python3.6/site-packages
$ python3 -m site --user-site
/home/king/.local/lib/python3.6/site-packages
$ conda install praw <----fails because cant find package
Tried the solution from here:
$ python3.6 -m pip install praw
PermissionError: [Errno 13] Permission denied: '/home/king/anaconda3/lib/python3.6/site-packages/update_checker.py'
$ sudo -H python3.6 -m pip install praw
sudo: python3.6: command not found
All my python directories
/home/king/anaconda3/lib/python3.6/site-packages
/usr/local/lib/python3.5/dist-packages/
/usr/local/lib/python2.7/dist-packages/
anaconda does not provide pip3, if anaconda is first in your path, use pip. Check with
which pip
To be sure, you are using the pip that corresponds to your python, use:
python -m pip install ...
Edit: Looks like you messed up file permissions of your anaconda install. Maybe by using sudo to install something.
To fix, you could do:
sudo chown -R king:king /home/king/anaconda3
and don't use sudo again to do stuff with the anaconda install in your home.
first of all, it's highly recommanded to install Anaconda to /opt in order to be used by all users (avoid permission problem)
Try to see witch python you use (Anaconda or Native Python) to see with pip you use:
which python
if you find that python you use is on /usr/local/lib that mean you use the native one, so tou have to export the Anaconda/bin to you environment variable to use Anaconda python. and then you can use pip to install your package:
pip install praw

How do I can install pip inside virtual environment

I have created one virtual-environment. Inside that I have to install few python packages. For that I need pip package inside virtual environment. How can I install pip inside virtual-environment?
According to the pip documentation, you can install pip in a virtual environment by typing the following command when your virtual environment is activated:
python -m ensurepip --upgrade
For your information, ensurepip is an in-built Python module that serves the purpose of installing pip in your Python environment.
you can also try with upgrading pip command even after no pip installed at you specified virtual location
python -m pip install --upgrade pip
This will give you an error as below but also install latest pip version on virtual location
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-19.2.3
kindly try above option and let me in case any issue.
Usually, you install pip OUTSIDE of your virtual environment.
But after activating the virtualenv you just run "pip install" inside the environment.
Meaning, you install it outside the virtualenv.
You run "pip install" inside the virtualenv.
You can follow this useful guide:
http://docs.python-guide.org/en/latest/dev/virtualenvs/
When you create a virtual environment for a particular python revision installed in your computer, all the libraries currently installed in your python revision would be copied inside the virtual environment.
Pip is usually default available in your python revision directory.
If not, install it first in your original python install directory.
Then copy the pip.exe to the virtual environment's Scripts directory.
After that execute the below command from your terminal (this is for Windows):
\your_venv_directory_path\Scripts\pip.exe install --upgrade pip
Now you can just type
pip install --upgrade pip
and it should recognise the path to the pip.exe file inside your venv
when creating the virtual-environment, be sure to include pip in the command. e.g:
conda create -n my_env pip python=3.6.8
I would suggest deleting the venv and recreating it using the above command

Categories