Reputation: 349
My goal is to install a package to a specific directory on my machine so I can package it up to be used with AWS Lambda.
Here is what I have tried:
pip install snowflake-connector-python -t .
pip install --system --target=C:\Users\path2folder --install-option=--install-scripts=C:\Users\path2folder --upgrade snowflake-connector-python
Both of these options have returned the following error message:
ERROR: Can not combine '--user' and '--target'
In order for the AWS Lambda function to work, I need to have my dependencies installed in a specific directory to create a .zip file for deployment. I have searched through Google and StackOverflow, but have not seen a thread that has answered this issue.
Update: This does not seem to be a problem on Mac. The issue described is on Windows 10.
Upvotes: 22
Views: 32141
Reputation: 546
We encountered the same issue when running pip install --target ./py_pkg -r requirements.txt --upgrade
with Microsoft store version of Python 3.9.
Adding --no-user
to the end of it seems to be solving the issue. Maybe you can try that in your command and let us know if this solution works?
pip install --target ./py_pkg -r requirements.txt --upgrade --no-user
Upvotes: 45
Reputation: 1102
I ran into this with:
az extension add --name storage-preview
Fixed with:
$ cat $HOME/.config/pip/pip.conf
[install]
user = false
Related to this answer: Configure pip to install everything as with --user
Upvotes: 0
Reputation: 47
similar issue resolved it by adding --no-user
AzureAD+Irfan@irfan MINGW64 ~/Documents/aws deployment package (main)
$ pip3 install fastapi -t .
ERROR: Can not combine '--user' and '--target'
AzureAD+Irfan@irfan MINGW64 ~/Documents/aws deployment package (main)
$ ^C
AzureAD+Irfan@irfan MINGW64 ~/Documents/aws deployment package (main)
$ pip3 install fastapi -t . --no-user
Collecting fastapi
Using cached fastapi-0.92.0-py3-none-any.whl (56 kB)
Collecting starlette<0.26.0,>=0.25.0
Using cached starlette-0.25.0-py3-none-any.whl (66 kB)
Collecting pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2
Using cached pydantic-1.10.5-cp39-cp39-win_amd64.whl (2.2 MB)
Collecting typing-extensions>=4.2.0
Using cached typing_extensions-4.5.0-py3-none-any.whl (27 kB)
Collecting anyio<5,>=3.4.0
Using cached anyio-3.6.2-py3-none-any.whl (80 kB)
Collecting idna>=2.8
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting sniffio>=1.1
Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Installing collected packages: typing-extensions, sniffio, idna, pydantic, anyio, starlette, fastapi
Successfully installed anyio-3.6.2 fastapi-0.92.0 idna-3.4 pydantic-1.10.5 sniffio-1.3.0 starlette-0.25.0 typing-extensions-4.5.0
Upvotes: 0
Reputation: 75
Adding --no-user
at the end does work, and by far the easiest solution.
Upvotes: 5
Reputation: 379
I got a similar error recently. Adding my solution so that it might help someone facing the error due to the same reason.
I was facing an issue where all my pip installed packages were going to an older python brew installation folder.
As part of debugging, I was trying to install awscli-local
package to user site-package using:
pip install --user awscli-local
Then I got:
ERROR: cannot combine --user and --target
In my case, it was due to the changes in pip config I had set some time back for some other reason. I had set the 'target' config globally - removing which removed this error and my actual issue I was debugging for.
Check the following if solutions given above doesn't resolve your issue:
try the command:
pip config edit --editor <your_text_editor>
For me:
pip config edit --editor sublime
This will open the current config file where you can check if there's any conflicting configuration like the 'target' set in my case.
Upvotes: 1
Reputation: 99
We had the same issue just in a Python course: The error comes up if Python is installed as an app from the Microsoft app store. In our case it was resolved after re-installing Python by downloading and using the installation package directly from the Python website.
Upvotes: 9