I get ImportError whenever I try to install outside of site-packages - pip

When I try:
which -a pip
I get
bailin#LAPTOP-J4I3G886:~/miniconda3/bin$ which -a pip
/home/bailin/.local/bin/pip
/home/bailin/miniconda3/bin/pip
/usr/bin/pip
/bin/pip
Should I get rid of most of the pips? I'm on windows 10, wsl2 ubuntu miniconda3

most unix system comes with python, meaning it comes with pip too. After installing miniconda, I had another pip, that should've been overwritten but didn't. The fix is go to your bashrc file and add this:
alias pip=/home/usr/miniconda3/bin/pip
replace path with wherever your pip is

Related

I see pip in the python/python39/scripts folder but it still says "pip command not found"

I tried pip3, it still doesn't do anything. I tried to reinstall it from reinstalling python or installing it in idle, but if i try to do "python get-pip.py" it just goes to another line, it doesnt do anything. im on windows btw
Edit: I followed what the commenter said, and if i type "py -m pip install" it lets me install a package so tysm
Try adding pip to environment variables . Original answer
On Windows pip3 should be in the Scripts path of your Python installation:
C:\path\to\python\Scripts\pip3
Use:
where python
to find out where your Python executable(s) is/are located. The result should look like this:
C:\path\to\python\python.exe
or:
C:\path\to\python\python3.exe
You can check if pip3 works with this absolute path:
C:\path\to\python\Scripts\pip3
if yes, add C:\path\to\python\Scripts to your environmental variable PATH

Cannot create and activate a virtual environment on Git Bash with Python 2.7, Windows

I am using Git Bash on windows with python 2.7 and I want to work in a virtual environment.
When I type
virtualenv venv
Bash says
bash: virtualenv: command not found
That makes me think virtualenv is not installed, then I try to install virtualenv
pip install virtualenv
But again Bash says
bash: pip: command not found
Then by reading this thread python 2.7: cannot pip on windows "bash: pip: command not found" I find out that it cannot find the pip directory, that maybe is the same reason for which it cannot find virtualenv directory.
So I specify the path of pip and I try again to instal virtualenv
python -m pip install virtualenv
It installs virtualenv but then tells
DEPRECATION: Python 2.7 will reach the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python
2.7.
So I go forward and try to activate my virtualenv by typing
virtualenv venv
and as I expected I get the same error of before
bash: virtualenv: command not found
that I try to solve in the same way I did for pip, by typing
python -m virtualenv venv
and this time bash responds with
$ python -m virtualenv venv New python executable in
C:\Users\Tommaso\DJANGO~1\UDEMYD~1\METAGL~2\venv\Scripts\python.exe
Installing setuptools, pip, wheel... done.
So I guess it created my virtualenv named venv, but in my bash terminal I still get the writing "(master)" at the end of the input line, that I guess it means the virtual environment is not active.
How do I activate it?
Solved!
Here is what I did.
First, by following this SO answer, I found out how to make Git Bash use python 3.7 instead of python 2.7 by default:
I opened the file aliases.sh with Notepad++, located at
C:<path where you installed Git Bash>\etc\profile.d\aliases.sh
Under the paragraph
--show-control-chars: help showing Korean or accented characters
I added these lines indicating where the two versions of python I want to switch are located
alias python2='C:/<installation_path_of_python_2.7>/Python 2.7/python.exe'
alias python='C:/<installation_path_of_python_3.7>/Python 3.7/python.exe'
alias pip='C:/<installation_path_of_python_3.7>/Phyton/Scripts/pip.exe'
alias virtualenv='C:/<installation_path_of_python_3.7>/Phyton/Scripts/virtualenv.exe'
You don't really need the last 2 ones, but it will help you a lot, since it enables Git Bash to call pip, virtualenv and other scripts without writing python -m before the name of the script.
You can check out if you did right by typing
python -i
It should return you the latest python version you specified.
Then if I type
python -m virtualenv venv
It installs the virtual environment in the current directory
To activate that, just type
. venv/scripts/activate
If it works, you should see
(venv)
near to your active input line.
To deactivate it just type
deactivate
I had the same problem before. The solution is to install virtualenv first using pip. Then:
enter virtualenv nameOfTheEnvironment
nameOfTheEnvironment\Scripts\activate
You should see something like:
C:\Users\bamidele\Documents\DjangoProjects>virtualenv venv
created virtual environment CPython3.7.2.final.0-64 in 15334ms
creator CPython3Windows(dest=C:\Users\bamidele\Documents\DjangoProjects\venv, clear=False, global=False)seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=C:\Users\bamidele\AppData\Local\pypa\virtualenv\seed-app-data\v1.0.1)activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
C:\Users\bamidele\Documents\DjangoProjects>venv\Scripts\activate
(venv) C:\Users\bamidele\Documents\DjangoProjects>```
I hope this solves your problem.
In git bash, cd into the virtual environment(venv) directory of your project and use this command
source ./Scripts/activate
to activate virtual environment(venv)
You can go
cd venv\Scripts
path. Then:
Run the command
activate
This run on my Flask project.

How do I pip install pandas under the new system?

I have pip installed many packages using the windows powershell from my python 37 window, but havent for a few months and now I am getting an error instead of an install.
I have tried installing two packages (pandas and numpy) and get the same results for both.
I tried switching pip and pandas, as well as pip and the file name (including extension) and received no favorable results. When I type in the name of the module it returns that there is no module with that name, when I type in the full file name for the module it tells me that numpy-1 does not exist.
As you will see in the next section the problem seems to be that the pypi.org format for pip installing seems to have changed when I wasn't paying attention.
my code (which has worked in the past) looks like this
py -3.7 -m pip install numpy-1.16.2-cp37-cp37m-win_amd64.whl
the error looks like this
PS C:\Users\Hezekiah\AppData\Local\Programs\Python\Python37> py -3.7 -m pip install numpy-1.16.2-cp37-cp37m-win_amd64.whl
C:\Users\Hezekiah\AppData\Local\Programs\Python\Python37\python.exe: No module named pip
I expect my pip install code to install numpy, instead it tells me that pip is not a module.
follow steps
1.open cmd
2.give full path to the script folder
e.g.
C:\Python37-32\Scripts
3.then try pip commands
pip install pandas
C:\Python37-32\Scripts>pip install pandas

Changing pip installation path; OSError: [Errno 20] Not a directory

For context, I'm trying to point pip at the directory that PyCharm is using. Running OSX High Sierra. Google hasn't had any answers yet (As far as I can tell).
In the command line, if I enter
pip install SpeechRecognition -t /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4/site-packages
It gives me
OSError: [Errno 20] Not a directory
If I try
pip install SpeechRecognition -t /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4/
I get
ERROR: Target path exists but is not a directory, will not continue.
I tried updating pip, and still no luck. What should I try next?
The target dir you're trying to specify is incorrect - it should be
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
(lib dir instead of bin that stores the executables).
However, it looks like you are trying to install into the python dist's default site packages dir - you shouldn't need to explicitly specify the target dir in this case. Instead, use the correct pip executable:
$ pip3.4 install SpeechRecognition
If pip3.4 executable is not available, use the one bundled with Python 3.4:
$ python3.4 -m pip install SpeechRecognition

PySide Installation

I'm trying to install the PySide on python 3.5 (32-bit) on windows 10, I installed the pip, it's ok, but when I run the command 'easy_install' at cmd, shows this:
Subtitle: "-U" is not recognized as an internal or external command, operable program or batch file
When I run the command 'import easy_install' on python's console, it's ok nothing is shown here, but When I run "import PySide' shows the error 'ImportError: No module named 'PySide'"
Anyone knows why it occurs?
I don't have any experience using easy_install, but I wonder if you should try --upgrade instead of -U. Also, don't know if you want the upgrade flag at all if you don't have the package installed in the first place.
You mentioned you have pip installed, so you can install PySide like this:
python -m pip install PySide
Or if you are trying to upgrade PySide:
python -m pip install PySide
Note that you'll need python in your PATH environment variable, otherwise you'll need to provide the full path to the python interpreter, wherever that may be on your system:
C:/python27/python.exe -m pip install --upgrade PySide

Resources