Why does pip fail when installing local egg repository? - python

I am working on Windows 7.I have created a python egg using distutils. Now I try to install this egg in a virtual environment using pip 1.0.2 using the following command:
Then I create a virtual environment myVirtualEnv I activate it using activate.bat then execute the following command:
pip install path_to_my_local_folder#eggName
This creates a copy of my egg in my myVirtualEnv\build directory but I have the following error:
IOError: [Errno 2] No such file or directory: path_of_my_virtualEnv\build\PyEqdR\setup.py
Do you know why pip is looking for the setup.py file. Should I include it in the egg ?

http://www.pip-installer.org/en/latest/other-tools.html#pip-compared-to-easy-install
pip doesn’t do everything that easy_install does. Specifically:
It cannot install from eggs. It only installs from source.

I just came across this page and since I had the same exact problem, I thought to post the solution that worked for me.
This is an issue with the older versions of pip. My version of pip was 1.5.4. I was not able to find the first version of pip that was able to do it but the current version 6.0.6 does the job.
To update to latest pip version, simply run the following command:
pip install --upgrade pip
Needless to say if you want this to only take effect inside your virtual environment, run it inside the environment. Otherwise, run it globally.

Related

Can't upgrade pip in windows [duplicate]

On Windows, if you try to use pip to upgrade itself, inside a virtualenv, you may get a mysterious "access is denied" error. For instance:
D:\scratch\> C:\Program Files\Python\3.7.4\x64\python.exe -m venv D:\scratch\my-venv
D:\scratch\> D:\scratch\my-venv\Scripts\activate
(my-venv) D:\scratch\> pip install --upgrade pip
Collecting pip
Downloading pip-19.3.1-py2.py3-none-any.whl (1.4MB)
Installing collected packages: pip
Found existing installation: pip 19.0.3
Uninstalling pip-19.0.3:
Could not install packages due to an EnvironmentError:
[WinError 5] Access is denied: 'd:\\scratch\\my-venv\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.
This happens whether or not the command prompt has administrative privileges.
We know we have write access to everything inside d:\scratch\my-venv, because we just created it with the initial python -m venv command. The advice to use the --user option is unhelpful, since we want to upgrade the version of pip inside the virtualenv, which --user will not do.
What could be wrong, and what is the correct way to upgrade pip inside a virtualenv on Windows?
I don't know if this is the only reason this can happen, but notice that the "Access is denied" error points at d:\scratch\my-venv\scripts\pip.exe. pip is trying to replace itself, and Windows doesn't allow you to modify a running EXE file in any way.
A workaround for this specific problem is to use python -m pip install --upgrade pip instead. This way, pip.exe is not running, so Windows will allow it to be replaced. This action doesn't try to overwrite d:\scratch\my-venv\scripts\python.exe, and Windows doesn't care what pip does to all the other files belonging to the pip package.
See https://github.com/pypa/pip/issues/188 and https://github.com/pypa/pip/issues/1299 for further information.
You must have the same version of pip installed in windows as in the virtual env. I think that is the reason for the error Access Denied in Virtual Env.
in promt,
python -m pip install --upgrade pip
located in the Scripts folder of the virtual env, execute the update command upgrade pip in venv
I would have put this in a comment to zwol's answer, but I don't have enough reputation yet.
I just wanted to add to anyone else potentially coming across this from google like I did, that python -m pip install --upgrade pip did fix this issue for me. However if you try pip install --upgrade pip before doing that, something happens in the process before you hit the access denied error that messes up pip. I personally was getting ModuleNotFoundError: No module named 'pip' after trying to upgrade the normal way.
Once I deleted and restarted my virtualenv and had the first command be python -m pip install --upgrade pip It worked just fine.
I hope that helps other newbies out there struggling like me! :)
Same error for me, but in both conditions: my system pip and virtualenv pip. So, when I tried to upgrade my system pip, hopefully it wasn't like totally deleted, I could still use the "pip" command. However I know the upgrade system pip failed. When I tried the command again, it said pip was on the latest version. Maybe this is just a glitch. I believe it is the same for virtual environments(virtualenv, venv). When I upgrade the system pip I get this error:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\heewo\\AppData\\Local\\Temp\\pip-uninstall-8ob_krif\\pip.exe'
Consider using the `--user` option or check the permissions.
I know this is not normal. But still, different than the virtualenv, "pip" is still installed. I believe this is still ignorable as this is just a known issue and most people here know about this topic. For me, python -m pip install --upgrade pip did not work in this state.
I tried this method, and this did work for me.
virtualenv --pip [VERSION]
and replace VERSION with the latest version available on pip. This prints out that what version you are attempting to upgrade to, when you get the error.
And that should do the trick.

Scripts folder installs empty python 3.10.3

So im pretty new to python and i need pip for something i wanna do, but everytime i install python the Scripts folder where pip should be always installs empty. I make sure that install pip is checked when downloading python. How do I get it to install pip with python?
If you installed Python, it came bundled with pip.
The default packages:
C:\Users\<Your username>\AppData\Local\Programs\Python\Python310\Lib\site-packages
A better practice is to install a venv for every project you are working on. Every venv will have its own set of dependencies(i.e. packages), and it will be easier to manage them.
You can find installed packages in your venv:
YOUR_PROJECT_PATH\venv\Lib\site-packages
EDIT
From official docs:
Pip not installed¶ It is possible that pip does not get installed by default. One potential fix is:
python -m ensurepip --default-pip
There are also additional resources
for Installing pip

Installing pip and numpy on Unix server without root access

I know this question has been asked and answered a number of times but none of those solutions have worked for me. I have installed Python 2.7 into a local directory and added it to my path. When I try to install numpy i get the following error:
ImportError: No module named setuptools
I cannot simply sudo apt-get install python-setuptools because i don't have root access.
I need to install numpy and ideally have pip working for future applications.
0) Try to install packages that are isolated to the current user, use the --user flag:
pip install --user SomeProject
1a) I agree with #Pi Marillion here, use an isolated conda environment if you don't have root access. This way you keep your path clean.
To install conda:
Since I don't know about your OS, go to https://docs.conda.io/en/latest/miniconda.html
After installation, update your conda (just in case):
conda update conda
To list the installed packages, you can do
conda list
You should see python installed. you can start an interpreter by typing python in the terminal.
There's conda cheat sheet that I found incredibly helpful:
https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html
b) Now try installing via pip and I think you might need python 3.x for setuptools.
https://packaging.python.org/tutorials/installing-packages/#id13
2) If this does not work you can still try
https://packaging.python.org/guides/installing-stand-alone-command-line-tools/
Hope this helps :)
First try easy_install --user setuptools pip. If that doesn't work you need to install things manually.
Download setuptools-*.zip from https://pypi.org/project/setuptools/#files. Unzip the archive, cd into the new directory and run python2.7 setup.py install.
Then try pip install. If it still doesn't work reinstall pip: download get-pip.py and run python get-pip.py --user.

how to install setuptools in mac

I'm trying to install via pip some libraries but I'm having some problems.
When I try to install some of them I require for my project I get this message:
$ sudo pip install dj-database-url==0.2.0
Downloading/unpacking dj-database-url==0.2.0
Downloading dj-database-url-0.2.0.tar.gz
Cleaning up...
setuptools must be installed to install from a source distribution
It also happens when trying to install distribute==0.6.24
Any ideas?
Download ez_setup.py module from https://pypi.python.org/pypi/setuptools
Open a Terminal.
cd to the directory where you put the ez_setup.py.
Type python ez_setup.py and run it.
You should have it then.
After a pip install command I was getting the same error as you ("setuptools must be installed to install from a source distribution"). Since I couldn't find a solution, it was a lot faster to reinstall the virtual environment where python was running from.
If you're using virtualenvwrapper this is very easy. First you remove your problematic virtual environment (let's say it is called "venv") with:
rmvirtualenv venv
Then you setup a new one with the same name:
mkvirtualenv venv
And finally you install all your packages, including the one you had problems with:
pip install dj-database-url

pip freeze does not show all installed packages

I am using a virtualenv. I have fabric installed, with pip. But a pip freeze does not give any hint about that. The package is there, in my virtualenv, but pip is silent about it. Why could that be? Any way to debug this?
I just tried this myself:
create a virtualenv in to the "env" directory:
$virtualenv2.7 --distribute env
New python executable in env/bin/python
Installing distribute....done.
Installing pip................done.
next, activate the virtual environment:
$source env/bin/activate
the prompt changed. now install fabric:
(env)$pip install fabric
Downloading/unpacking fabric
Downloading Fabric-1.6.1.tar.gz (216Kb): 216Kb downloaded
Running setup.py egg_info for package fabric
...
Successfully installed fabric paramiko pycrypto
Cleaning up...
And pip freeze shows the correct result:
(env)$pip freeze
Fabric==1.6.1
distribute==0.6.27
paramiko==1.10.1
pycrypto==2.6
wsgiref==0.1.2
Maybe you forgot to activate the virtual environment? On a *nix console type which pip to find out.
You can try using the --all flag, like this:
pip freeze --all > requirements.txt
Although your problem was specifically due to a typo, to help other users:
pip freeze doesn't show the dependencies that pip depends on. If you want to obtain all packages you can use pip freeze --all or pip list.
If you have redirected all the pre-installed packages in a file named pip-requirements.txt then it is pretty simple to fix the above issue.
1) Delete your virtualenv folder or create new one (I am giving it a name as venv)
rm -rf venv && virtualenv venv
2) Install all the requirements/dependencies from the pip-requirements.txt
pip install -r pip-requirements.txt
3) Now you can check the installed packages for your Django application
pip freeze
4) If you had forgotten to update your requirements file(pip-requirements.txt), then install fabric again (Optional Step)
Note: After installing any dependency for your Django app, always update the requirements in any file as follows (make sure your virtualenv is activated)
pip freeze > pip requirements.txt
That's it.
Adding my fix in addition of above fix also ,
I was also facing the same issue on windows,even after activating the virtualenv too pip freeze was not giving me all list of installed packages. So i upgraded my pip with python -m pip install --upgrade pip command and then used pip freeze.
This time it worked and gave me all list of installed packages.
This might be stupid but I have got the same problem. I solved it by refreshing vs code file directory (inside vscode there is a reload button). :)
If none of the above answers are working for you.
As with me you might have problem in you venv and pip configuration.
Go inside your venv/bin and open pip and see the 2nd line as:
'''exec' "path/to/yourvenv/bin/python3" "$0" "$#"
See if this line is correctly pointing inside your venv or not
For example in my case.
I initially named my virtual environment as venv1
and later just renamed it to venv2.
In doing so my pip file 2nd line had: '''exec' "venv1/bin/python3" "$0" "$#"
which to work properly should have: '''exec' "venv2/bin/python3" "$0" "$#" notice "venv2" not "venv1" since venv1 in now renamed to venv2.
Due to this python was looking inside pip of venv2 and throwing error or not working as desired.
For those who added Python modules via PyCharm IDE, after generating a virtual environment from the command prompt, good luck! You will need to rebuild the requirements.txt file manually with the ones missing by first running pip3 freeze and adding what is missing from PyCharm.
I highly suggest switching to Visual Studio Code.

Categories

Resources