Setup django/python with Jenkins - python

I currently configure Jenkins for my python/django application (i'm using python 3.5)
During the setup I open a Virtualenv and I activate it.
virtualenv -q wecover_platform .
./wecover_platform/bin/activate
Then i install all my requirements from my file requirement.txt
pip install -r $WORKSPACE/requirements.txt
I can't pass this step i always have a permission denied issue.
Installing collected packages: asn1crypto, pycparser, cffi, idna, cryptography, pyOpenSSL, olefile, pillow, reportlab, selenium, django-jenkins
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/asn1crypto'
Build step 'Execute shell' marked build as failure
Finished: FAILURE
If somebody could help me I would really appreciate it!

Related

Can't use pip on macbook

I got this when using pip install.
> pip install cognitive_face
Collecting cognitive_face
Using cached cognitive_face-1.2.5.tar.gz
Collecting requests (from cognitive_face)
Using cached requests-2.13.0-py2.py3-none-any.whl
Installing collected packages: requests, cognitive-face
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/requests'
I can find file "python3" and "python3.6" in my /usr/local/bin and folder "python3" in/usr/local/Cellar.
Also my emacs25 can't do run-python and showing:
Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native’ was t and "python3.6" is not part of the ‘python-shell-completion-native-disabled-interpreters’ list. Native completions have been disabled locally.
OS Version: 10.12.3
It's a permission issue. Use sudo
sudo pip install cognitive_face
You need admin rights. Use sudo pip ….

Installing Pandas on MacOs. Permission Error

I am trying to pip install pandas on a mac. I have python 3.6 installed.
When I pip install in the terminal I get the following error:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pandas'
Could you possibly edit the error into a formatted code block by highlighting it and pushing ctrl+k so it is easier to read? Thanks.
Edit: Also, I just looked through and at the bottom it says permission denied. Try rerunning the command as an admin. I.E try this command:
sudo pip install pandas
You might have already noticed, Mac come with a built in Python, python 2.7. If you read your traceback: /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py it's pointing to the 2.7 dir. this dir is in the Library folder so you don't have permission to install to it.
But you state that you have Python 3.6 installed as well, so if you wanted to install to that indtead. Do pip3 install pandas or python3 -m pip install pandas this help specify the python version. And if you want to run python 3.6 in terminal, type python3 instead of just python

pip freeze is giving me the global packages

I'm fairly new to python so please bear with me. I installed the virtual env created a new environment and everything very smooth(great). so when I try to pip freeze it gives me all the global packages that are installed and not only the environment im in. Then I try to install django and it does not let me. This is the error that gives me...
→ pip install django
Collecting django
Downloading Django-1.9.5-py2.py3-none-any.whl (6.6MB)
100% |████████████████████████████████| 6.6MB 187kB/s
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_set.py", line 732, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_install.py", line 835, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_install.py", line 1030, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/wheel.py", line 344, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/wheel.py", line 315, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'
OK. I got it working. The problem was something with a cache directory. When I reinstalled virtualenv I used a flag plus sudo.
sudo pip install --no-cache-dir virtualenv
but new questions comes up.
How important is a cache directory for the environments?
Do I need one yes o no?
Thanks all for your awesome help.

Installing pywin32 - win32api.pyd permission denied

I need to use win32api for rpy2. So I went to http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32 and tried to install it with pip. However, I have got the errors below. How can I overcome this permission denied problem?
C:\Anaconda\Scripts\pip-script.py run on 07/09/15 16:48:30
Unpacking c:\users\myname\downloads\pywin32-219-cp34-none-win_amd64.whl
Installing collected packages: pywin32
Found existing installation: pywin32 218.4
Uninstalling pywin32:
Removing file or directory c:\anaconda\lib\site-packages\pywin32-218.4-py2.7.egg-info
Successfully uninstalled pywin32
Rolling back uninstall of pywin32
Replacing c:\anaconda\lib\site-packages\pywin32-218.4-py2.7.egg-info
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Anaconda\lib\site-packages\pip\basecommand.py", line 134, in main
status = self.run(options, args)
File "C:\Anaconda\lib\site-packages\pip\commands\install.py", line 241, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "C:\Anaconda\lib\site-packages\pip\req.py", line 1298, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "C:\Anaconda\lib\site-packages\pip\req.py", line 595, in install
self.move_wheel_files(self.source_dir)
File "C:\Anaconda\lib\site-packages\pip\req.py", line 815, in move_wheel_files
move_wheel_files(self.name, self.req, wheeldir, user=self.use_user_site, home=self.target_dir)
File "C:\Anaconda\lib\site-packages\pip\wheel.py", line 172, in move_wheel_files
clobber(source, lib_dir, True)
File "C:\Anaconda\lib\site-packages\pip\wheel.py", line 166, in clobber
shutil.move(srcfile, destfile)
File "C:\Anaconda\lib\shutil.py", line 301, in move
copy2(src, real_dst)
File "C:\Anaconda\lib\shutil.py", line 130, in copy2
copyfile(src, dst)
File "C:\Anaconda\lib\shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: 'C:\\Anaconda\\Lib\\site-packages\\win32\\win32api.pyd'
If it's only a "permission denied" situation, try adding sudo before pip (Note: must be # owner/administrator level)

What is the error I am facing when I am installing Django via PIP in a virtualenv?

On my OSX 10.10.2, in a virtualenv, I tried to install Django via pip using the command:
pip install django
And this the responds I got:
Collecting django
Downloading Django-1.7.7-py2.py3-none-any.whl (7.4MB)
100% |################################| 7.4MB 58kB/s
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_set.py", line 549, in install
**kwargs
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_install.py", line 754, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_install.py", line 963, in move_wheel_files
isolated=self.isolated,
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/wheel.py", line 266, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/wheel.py", line 212, in clobber
shutil.copyfile(srcfile, destfile)
File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/shutil.py", line 109, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/Users/qmbp/.virtualenvs/demo/bin/django-admin.py'
I guess the issue is caused as I did not prefix sudo to the command. But I read that it was a good idea to use sudo in OSX. And that is why virtualenv is encouraged as sudo is not needed inside it.Here is a screenshot of my files as I could not find the "env" in the bin folder.
Looks like you forgot to activate your venv.
Try:
source path_to_your_venv/bin/activate
pip install django

Categories

Resources