I am trying to install "XLRD" library for python using PIP install, the library is installed successfully, after execution i tried to import the same but i get the error that no modules have been installed.
After some research i found that everything is getting installed in the C:jython/site-packages directory instead of C:/python27.
My pythonpath is set to C:/python27 , I checked.
What could be the issue? How do i instruct PIP to install modules in python directory.
On your terminal/command prompt navigate to the Python home directory of the version for which you need to install the module. Then navigate into the scripts folder and run the pip command. Like below
cd C:/python27/Scripts
pip install XLRD
You basically need to point to the pip script for which you need to run this command. If thats for the pip script inside the python27, you need to navigate there or do like below as well
C:/python27/Scripts/pip install XLRD
If you have both the python27 & jython home directory & script paths in your 'PATH' environment variables, the path that was declared first takes precedence. To rearrange precedence, you would have to rearrange the order of the path declaration.
Related
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.
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.
My goal is to import a couple third party Python packages for use with my GIMP installation. This will allow me to use these packages when developing a GIMP plugin. I noticed a few directories that may be of use. They are as follows:
C:\Program Files\GIMP 2\32\lib\python2.7
This directory contains a site-packages folder which contains packages such as requests and pip.
C:\Program Files\GIMP 2\32\bin
This directory contains a python.exe. When I run python --version in an elevated cmd at this directory path, the output is Python 2.7.16, which I assume is GIMP 2.10's version of Python. This is important because I have my own installation of Python 3.8.0 in my Program Files. If I'm anywhere outside of this path in the cmd, the version that outputs is 3.8.0.
I have added these directories to my PATH system variable and tried running pip install but the output tells me I have already installed the requested third party packages. The problem is that they are installed to my Python 3.8.0 installation. I'm trying to run pip install in the context of GIMP's Python environment.
Any advice would be much appreciated.
Grab get-pip.py here
Put it into your GIMP Python directory (C:\Program Files\GIMP 2\Python)
From a Windows Command Prompt Window cd to that directory
Run get-pip with this python instance: .\python.exe get-pip.py. You now have pip installed in the GIMP version of Python.
You can now use this pip instance with Gimp's Python runtime: .\python.exe -m pip install --user <package>
Uplifted/adapted from here
Turns out the package I was trying install had dependencies that required a higher version of Python than the one GIMP comes with. Thanks to those whom responded.
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.
I'm trying to run a certain script in Python, but it requires some other modules (setuptools) - I don't have write permissions for our /usr/ directory to install them, so I'm trying to install a local version of Python 2.7 to run it (not in /usr/).
When I try to run the ez_setup script for setuptools, it tries to access:
/usr/local/lib/python2.7/site-packages/
But that's not the installation I want (I get write permission error). I can point the ez_setup script to wherever, but I'm not sure how to get Python to use it. In my 2.7 install I ran:
site.getsitepackages()
['/usr/local/lib/python2.7/site-packages', '/usr/local/lib/site-python'].
Is there a way to change the default site-packages directory so I can do local installs? Like in the Python installation directory itself?
Thanks,
Kaleb
You really want to read up on Python virtual environments, which allow you to create a "local" Python tree into which you can install your own packages and such without requiring root access.
For example, assuming that you have the virtualenv command available (you may need to install this first; it's available as a package for most major distributions), you can create a new virtual environment like this:
virtualenv --system-site-packages myenv
The --system-site-packages option will make any packages in your system site-packages directory visible to this environment, as well as anything you install locally. Then activate the environment:
. myenv/bin/activate
And install stuff:
pip install apackage
NB For no good reason, pydoc will stop working for you in this configuration. You can just drop a new pydoc script into myenv/bin/pydoc that looks like this:
#!/usr/bin/env python
import pydoc
if __name__ == '__main__':
pydoc.cli()