PIP install package - installed but python is not importing - python

Running on Windows 10, I have Python 3.7.3 installed to my c/users/myUser/appdata/local/programs folder.
When I use PIP to install a package, it seems to run fine, but when I use "import package" in python it doesn't recognize that package. What would cause this?
Running 'python --version' works and also running 'pip --version' works.
PIP shows up in my c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip folder.
UPDATE:
So I was looking through files to determine where the libraries are located that do work with my python. The folder is located in Python/Python37-32/Lib. All of those currently work when importing. However when I do anything with PIP it does not add anything to that folder.
I noticed there are a couple different PIP executables within Python/Python37-32/Scripts which include pip.exe, pip3.exe, and pip3.7.exe. I tried using "pip3.7 install numpy" which also did not work.
I noticed when trying to add an existing package its pointing to the Python37-32/lib/site-packages folder.

SOLUTION:
I removed python from my machine, and reinstalled it. I had the same problem. What I done to fix this was to use
PS
python -m pip install --user package
Also I appended my PATH environment variable with
cmd
setx path "%path%;C:\Users\MyUser\AppData\Roaming\Python\Python38\Scripts"
That seemed to have taken care of my issue. Now when I install a package with PIP I can reference it through python.

Related

Why does it say that pygame is already installed but I can't use it [duplicate]

Running on Windows 10, I have Python 3.7.3 installed to my c/users/myUser/appdata/local/programs folder.
When I use PIP to install a package, it seems to run fine, but when I use "import package" in python it doesn't recognize that package. What would cause this?
Running 'python --version' works and also running 'pip --version' works.
PIP shows up in my c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip folder.
UPDATE:
So I was looking through files to determine where the libraries are located that do work with my python. The folder is located in Python/Python37-32/Lib. All of those currently work when importing. However when I do anything with PIP it does not add anything to that folder.
I noticed there are a couple different PIP executables within Python/Python37-32/Scripts which include pip.exe, pip3.exe, and pip3.7.exe. I tried using "pip3.7 install numpy" which also did not work.
I noticed when trying to add an existing package its pointing to the Python37-32/lib/site-packages folder.
SOLUTION:
I removed python from my machine, and reinstalled it. I had the same problem. What I done to fix this was to use
PS
python -m pip install --user package
Also I appended my PATH environment variable with
cmd
setx path "%path%;C:\Users\MyUser\AppData\Roaming\Python\Python38\Scripts"
That seemed to have taken care of my issue. Now when I install a package with PIP I can reference it through python.

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.

Python 2.7 Pip module not installing or setting paths via cmd?

I've been having some really odd issues with trying to install and use the Python "Pip" module. Firstly, I've installed the pip module by downloading the getpip.py file and running it which has replaced my pre existing pip which seemed to work fine. However whenever I try to use pip it always comes up with "pip is not recognized as an internal or external command" etc. I've set the path for python by using setx PATH "%PATH%;C:\Python27\python" and then using C:\Python27\Scripts\pip the second time to try and set the path for pip. But one of these seem to work. I can't use pip in cmd neither can I now use python.
Does anyone know how to make this work? I'm trying to run this command "pip install -r requirements.txt " even in the right folder but pip is not recognized. Any suggestions? Thanks.
You're using the wrong path, Pip should reside in the Scripts sub directory, set PATH to C:\Python27\Scripts then you should restart cmd.

Installing python packages with no installation directory acces and no pip/easy_install/virtual_env

At work we have python installed, but no additional modules. I want to import some scipy modules but I have no access to the python directory for installation.
Similar questions have been asked on StackOverflow, but the answers always assumed easy install, pip or virtualenv were installed. At my workplace, none of these packages are installed. It's just the plain python installation and nothing else.
Is there still an option for me for installing modules in my local folder and calling them from python? If so, how do I go about it?
Not exactly installing modules on your local folder, but a solution nonetheless:
I used to work for a company that used windows and didn't have admin access, so I ended up using Portable python.
It seems portable python is no longer mantained, but you can see some other portable python solutions on their site, most of which you can run straight from your usb.
You can download pip from here http://pip.readthedocs.org/en/stable/installing/ and install it without root privileges by typing:
python get-pip.py --user
This will install to directory with prefix $HOME/.local so the pip executable will be in the directory $HOME/.local/bin/pip, for your convenience you can add this directory to $PATH by adding to end of .bashrc file this string
export PATH=$HOME/.local/bin/:$PATH
After this you can install any packages by typing
pip install package --user
Or you can alternatively compile the python distribution from source code and install to your home directory to directory $HOME/.local or $HOME/opt or any subfolder of $HOME you prefer, let's call this path $PREFIX. For doing this you have to download python source code from official site, unpack it and then run
./configure --prefix=$PREFIX --enable-shared
make install
And then add python binary to $PATH, python libraries to $LD_LIBRARY_PATH, by adding to the end of $HOME/.bashrc file whit strings
export PATH=$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/lib
and when after restarting bash you can also run
python get-pip.py
and pip and will be installed automatically to your $PREFIX directory. And all other packages those you will install with pip will be automatically installed also to $PREFIX directory. This way is more involved, but it allows you to have the last version of python.

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