How to change path to site-packages dir in easy_install - python

I'm trying to use easy_install on windows7x64 and getting this:
<output>
c:\Python27\Scripts>easy_install.exe django-piston
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 2] No such file or directory: 'C:\\Python27\\Lib\\site-packages\\Lib\
\site-packages\\test-easy-install-4132.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
C:\Python27\Lib\site-packages\Lib\site-packages\
This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
Where can I change easy_install's path to correct one "C:\Python27\Lib\site-packages"?

easy_install should install the packages in the Python installation's site-packages directory. It could have happened that you changed Python's directory accidentally.
Reinstalling easy_install should fix this.
Otherwise you could use:easy_install --install-dir C:\Python27\Lib\site-packages\Lib\site-packages\ django-piston
However, this last option has two issues:
Make sure C:\Python27\Lib\site-packages\Lib\site-packages\ is in PYTHONPATH
You will need to indicate a install-dir directory for every new package you install

Related

adding python binary distribution to path

I am trying to get the python package simms to work on my computing cluster. Unfortunately there isn't much documentation. I have
inside my conda env installed it via
pip install simms
I also git cloned https://github.com/ratt-ru/simms.git to
my_dir/simms
Then inside my conda env, running the suggested:
python my_dir/simms/tests/tests.py
gives an error
FileNotFoundError: [Errno 2] No such file or directory:
'casa': 'casa'
I have filled the instructions at
https://github.com/ratt-ru/simms/blob/master/tests/test.py to install the
CASA package (from https://casa.nrao.edu/installlinux.shtml) . After
uploading and unzipping, I added it to my path variable with
export PATH=$PATH: mydir/casa-6.5.2-26-py3.8
Note that casa-6.5.2-26-py3.8 has a subfolder bin/ so things Python should know where to look, but I still get the same FileNotFoundError.

custom python package installation with setup.py

I would like to install a python package (third party package written with cython for some numerical calculations).
My previous experience (which were successfully) is that, I only need to perform following command:
python setup.py install --prefix="/destination/path/"
Then, I would expect an additional folder as /destination/path/package
so, I can do
export PYTHONPATH=$PYTHONPATH:/destination/path/
So, I can finally import the package normally in python script.
However, it seems that the default behavior of setup.py (I am using anaconda python3.7) changed. When I use the same (first) command, I encounter an error as:
Checking .pth file support in /destination/path//lib/python3.7/site-packages/
/path/to/python -E -c pass
TEST FAILED: /destination/path/lib/python3.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/destination/path/lib/python3.7/site-packages/
Could someone explain to me what happened and how can I fix this error?
Thank you very much in advance.
Best,
Greg

Error "can't create or remove files in install directory" when installing by source code in Python

I am trying to setup my Python environment in cloud Linux. I copied the working folder "Artem's_strategy", which contains the source code setup.py, from local PC to the cloud LInux system. When trying to install setup.py I get the following error
[ec2-user#ip-xxx Artem's_strategy]$ python3 setup.py install
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 2] No such file or directory: '/usr/local/lib/python3.7/site-packages/test-easy-install-2160.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python3.7/site-packages/
This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
In other thread I found solution in the form of using --install-dir, which brings following error:
[ec2-user#ip-xxx~]$ /home/ec2-user/Artem\'s_strategy/setup.py --install-dir=/usr/local/lib/python3.7/site-packages
: No such file or directory
Checking the folder we can see that setup.py exists in this folder:
[ec2-user#ip-xxx Artem's_strategy]$ ls -la
total 1480
-rwxr-xr-x 1 ec2-user ec2-user 354 Mar 17 15:51 setup.py
So your help with installing from source code setup.py would be appreciated.
You should try this:
python setup.py install --user || exit 1
source: https://github.com/hughperkins/pytorch/issues/8
If you go into a terminal and execute:
python3 -m site
It should give you a response similar to the following:
sys.path = [
'/home/tyler',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/home/tyler/.local/lib/python3.6/site-packages',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/tyler/.local' (exists)
USER_SITE: '/home/tyler/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True
Using this, you can determine the directory in which your site-packages are stored and use the
--install-dir
parameter to install it there. Hope this helps!
After finding where your site-packages are installed, use --prefix=location in your command.
python3 setup.py install prefix=C:\\Users\\User\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages
I followed Tylerr's answer:https://stackoverflow.com/a/60727896/13916894 but instead of --install-dir used --prefix and it worked.
Not 100% sure if it will work but I had a similar issue with Flask Restful on my WSL
What worked for me was running the whole setup from https://flask-restful.readthedocs.io/en/latest/installation.html after having full permissions with
sudo su

Error: setup script specifies an absolute path: .gitignore

On Ubuntu 16.04.4, I suspect some recent update of some Python system package of having broken my Python 2.7 configuration. Whatever package I try to install or reinstall with a basic sudo python setup.py install it always fails because of gitignore:
running install
running bdist_egg
running egg_info
[...]
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
error: Error: setup script specifies an absolute path:
/home/me/some_repo/.gitignore
setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.
Lately I found a temporary workaround by manually cleaning the /usr/local/lib/python2.7/dist-packages/some_package directory manually before installing some_package. However tonight I'm facing the same issue on another repository and it keeps failing whatever I clean up. I also tried cleaning all compiled folders .egg-info/ build/ dist/ without success.
Notes: The setup script does not actually specify an absolute path to gitignore. An example of failing repo is https://github.com/philchristensen/python-artnet/blob/master/setup.py This repo has a setuptools_git entry which might lead to a clue, but other packages without this git entry point also fail because of the gitignore while a couple of months ago I never faced such issue with the same repos. Deleting the gitignore causes the setup to fail because of another non-py local file.
Any clue?
It looks like some other package that I had previously installed broke my system-wide Python.
Here's how I fixed in order to install package xyz:
Browsed /usr/local/lib/python2.7/dist-packages in search for occurences of "gitignore"
Deleted folders of all matching occurences (including setuptools_git itself that matches "gitignore")
pip install setuptools_git
In package xyz, rm -rf dist/ build/ *.egg-info/
Reinstall package xyz, which now succeeds to install
Use virtual envs as a lesson

OSError: [Errno 13] Permission denied when updating setuptools

I'm trying to update setuptools using homebrew but I keep getting an error that says:
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/setuptools-1.1.3-py2.7.egg'
How do I allow my computer to make changes to that file so I can update setuptools?
I figured out how to fix it! I looked up the name of that file setuptools-0.6c11-py2.7.egg and I found a python page on it that says
NOTE: Regardless of what sort of Python you're using, if you've previously installed older versions of setuptools, please delete all setuptools*.egg and setuptools.pth files from your system's site-packages directory (and any other sys.path directories) FIRST.
So I deleted setuptools-0.6c11-py2.7.egg and setuptools.pth in /Library/Python/2.7/site-packages/ then I went into terminal and typed in pip install --upgrade setuptools and it worked!
Open Finder and select Go - Go To Folder. Then hit Command-I, and at the bottom under Sharing and Permissions, add yourself with Read and Write Access. This should solve it.

Categories