I am trying to set up a virtualenv for the first time and I can't figure out what the issue is. Here is the output in terminal...
Traceback (most recent call last):
File "/bin/virtualenv", line 3, in <module>
virtualenv.main()
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 960, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1133, in install_python
mkdir(lib_dir)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 441, in mkdir
os.makedirs(path)
File "/usr/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: 'test_env'
I don't know why I would get a Permission denied error with just creating a virtualenv.
A virtualenv, on disk, is a directory with its own Python installation. The virtualenv utility needs to create this directory, and by default it puts it into your current directory (as opposed to some standardized location like ~/.venvs), which means that you need to be in the same directory as where you created the virtual environment every time you use it. The the Permission denied message comes from it not being able to create the directory in the first place.
Most likely you don’t have write permission to whatever directory you’re in. Your current directory (which you can find with pwd) should (usually) be somewhere in your home directory when trying to create a virtualenv.
Another possibility is that the directory already exists, but some of the necessary directory structure inside the virtualenv directory does not, and you don’t have write permission there. Usually, you want to use a name that does not correspond to an existing directory, and let the virtualenv tool create it for you.
Related
I dont have much experience in python, so it might be a stupid question.
Im trying to write to a file in my script, if I run the script from his folder, it works, however if I run it from another folder, I have an error 13 persmission denied
i.e. in cmd :
cd C:\Users\user010\Perforce\Build\LS3\
py Build_jenkins.py
works but
cd C:\Program Files (x86)\Jenkins\workspace\LC3.3 Test\Qt\main
py C:\Users\user010\Perforce\Build\LS3\Build_jenkins.py
doesnt work. I have tried moving the script and the file to a public folder, same error :
Traceback (most recent call last):
File "C:\Users\Public\Documents\Build\LS3\Build_jenkins.py", line 159, in <module>
Variables.Sauvegarder()
File "C:/Users/Public/Documents/Build/LS3/../Common\Variables.py", line 87, in Sauvegarder
gArbre.write( NOM_FICHIER )
File "C:\Python34\lib\xml\etree\ElementTree.py", line 761, in write
with _get_writer(file_or_filename, encoding) as write:
File "C:\Python34\lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Python34\lib\xml\etree\ElementTree.py", line 798, in _get_writer
errors="xmlcharrefreplace")
PermissionError: [Errno 13] Permission denied: 'Variables.xml'
The code is Variables.Sauvegarder() in my main file and in Variables :
import xml.etree.ElementTree as ET
gArbre = ET.parse( "Variables.xml" )
def Sauvegarder():
gArbre.write( "Variables.xml")
Edit : important detail I forgot to mention, the file im writing to is located in the script folder (C:/Users/Public/Documents/Build/LS3/../Common\Variables.xml)
To be honest, I'm not sure about Windows computers (for a mac or other linux-based system you'd use sudo), but I would recommend trying to run the command as an administrator (use the runas command plus the name of an account with admin priveledges.) That should hopefully fix the error you're getting.
I am very new to Python and Django and is currently busy learning myself through tutorials on www.djangoproject.com. I am using PyCharm and working on OS X El Capitan. I have imported a project from GitHub and created a virtual environment for the project interpreter based on Python 3.5.1. In the vm I installed django.
I then activated the vm.
Now.. I started by trying to execute simple commands in the terminal like python manage.py startapp deonapp and python manage.py runserver but each time I get an error which I pasted below.. What did I miss? I cannot seem to find the /log/ directory?
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 558, in configure
handler = self.configure_handler(handlers[name])
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 731, in configure_handler
result = factory(**kwargs)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/__init__.py", line 1008, in __init__
StreamHandler.__init__(self, self._open())
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/__init__.py", line 1037, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log/debug.log'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 795, in dictConfig
dictConfigClass(config).configure()
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 566, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'file': [Errno 2] No such file or directory: '/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log/debug.log'
I managed to fix it. The log directory was not created because it was excluded in the .gitignore file. I completely forgot to look what was excluded :). I created the directory manually and now it passed the error.
Deon
you can add this in setting.py
LOG_PATH = os.path.join(BASE_DIR, 'log')
or
if not os.path.join(LOG_PATH):
os.mkdir(LOG_PATH)
Other answers can be true in most of cases, But In my case log directory was created, But log dir had permission issue to my user. simply using chown to my user (my case www-data) solved the problem.
(In my case):
sudo chown www-data:www-data /var/log/django/
use your username:user-group instead of www-data:www-data and your log dir instead of /var/log/django/.
Traceback says, that it's no "log" directory.
Create directory with name log in path /Users/deon/Documents/PyCharmProjects/Developments/deonproject/
Create empty file .gitkeep
After creating .gitkeep file, push it to GitHub
Im learning Python.
Getting below exception while trying to clone a repos
Traceback (most recent call last):
File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 622, in execute
**subprocess_kwargs
File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 969, in __init__
restore_signals, start_new_session)
File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 1249, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "config_console.py", line 2185, in <module>
command_line = ConfigCommandLine()
File "config_console.py", line 87, in __init__
g.clone('git#github.com:Modria/Ecomm_GM.git')
File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 463, in <lambda>
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 905, in _call_process
return self.execute(make_call(), **_kwargs)
File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 625, in execute
raise GitCommandNotFound(str(err))
git.exc.GitCommandNotFound: [WinError 5] Access is denied
GitPython is installed. ssh keys are available in C:\Users\Selvakumar.ssh and its working when I clone from git bash. But the same not working from python. Please note that ssh keys are generated with no password. Please help me to resolve it
The OP confirms it is a PATH/variable issue
Does your PATH references git binary?
Yes, that was the mistake I did. I missed to git.exe in GIT_PYTHON_GIT_EXECUTABLE path variable.
Given like this as C:\Program Files (x86)\Git\bin\git.exe and it works.
You can see that variable introduced here in GitPython 26
If set, it should contain the full path to the git executable, e.g. c:\Program Files (x86)\Git\bin\git.exe on windows or /usr/bin/git on linux.
The GitPyhton README states:
GitPython needs the git executable to be installed on the system and available in your PATH for most operations.
If it is not in your PATH, you can help GitPython find it by setting the GIT_PYTHON_GIT_EXECUTABLE=<path/to/git> environment variable.
seems like an authority error, be sure to run your script as an administrator
I have a python script that builds a file by searching through folders and pulling in a list of files. This file runs fine and works as expected when I open and run it in IDLE, but if when I run the script in a commandline window I get this error:
C:\Windows\system32>python "C:\Users\ntreanor\Documents\RV Scripts\Server RV Sequence.py"
Traceback (most recent call last):
File "C:\Users\ntreanor\Documents\RV Scripts\Server RV Sequence.py", line 69,
in <module>
for foldername in os.listdir(pngFolders):
WindowsError: [Error 3] The system cannot find the path specified:
'Y:/20_temp_script_testing/pr126 movs\\04_comp_pngs/*.*'
In case it's not obvious, yes the path does exist. It not only works in IDLE but I double checked and the path definitely exists.
I also tried to create folders with a script that runs as a daemon and got a similar result
Traceback (most recent call last):
File "D:\shotgun\shotgunEventDaemon.py", line 888, in process
self._callback(self._shotgun, self._logger, event, self._args)
File "D:\shotgun\plugins\CreateAssetFolders.py", line 72, in createAssetFolders
os.makedirs(folder)
File "D:\Python27\Lib\os.py", line 150, in makedirs
makedirs(head, mode)
File "D:\Python27\Lib\os.py", line 150, in makedirs
makedirs(head, mode)
File "D:\Python27\Lib\os.py", line 150, in makedirs
makedirs(head, mode)
File "D:\Python27\Lib\os.py", line 157, in makedirs
mkdir(name, mode)
WindowsError: [Error 3] The system cannot find the path specified: 'Y:/'
This is what the script logged as a folder right before that:
Making folder:
Y:/07_design/04_environmental_elements\eec005-08_insect_ladybird_red_7_spots_wide
(the reason it's saying Y and not the whole path is that it attempts to make each folder back until it can't go back any further and that's when the exception is thrown)
Are the environment variables of the commandline window somehow affecting the drive mapping that should be pointing the script to the right location?
The issue is likely because IDLE and your command line are running with a different level of privileges. Mapped network drives are not automatically available to all user contexts. There is a superuser question on this here and plenty of other resources cover this topic. In short, the mapped network drive is only available to programs running at the level the mapping was made at.
If you have mapped the network drive through the windows UI, then it will be mapped for un-elevated programs. However if it was mapped with net use then it depends on the level of the command prompt when the mapping was made!
Disabling UAC will also affect change this behaviour, as will use of an elevated (or not) command prompt, which may explain why some PCs display different behaviour.
I think your problem is that you're trying to open the * file, which of course doesn't exist. open(path) takes path as a literal string and doesn't translate it in anyway, so it expects that value to be a valid filename. You should change your code to get a directory instead of a file, and then walking that directory.
I currently use a linux VM in VMWare running on a Windows machine. I have a shared Windows folder for my projects that I access in linux via /mnt/hgfs/
When I try to use virtualenv for my python projects I get an 'Operation not supported' error:
joe#myserver:/mnt/hgfs/winwww/envtest# virtualenv env
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.7', 'console_scripts', 'virtualenv')()
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 928, in main
never_download=options.never_download)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1029, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1164, in install_python
copyfile(join(stdlib_dir, fn), join(lib_dir, fn))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 430, in copyfile
copyfileordir(src, dest)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 405, in copyfileordir
shutil.copytree(src, dest, True)
File "/usr/lib/python2.6/shutil.py", line 173, in copytree
raise Error, errors
shutil.Error: [('/usr/lib/python2.6/config/libpython2.6.so', 'env/lib/python2.6/config/libpython2.6.so', '[Errno 95] Operation not supported')]
I'm assuming this is due to Windows not being able to handle symbolic links because I can create my virtualenvs in other directories.
Has anyone worked out a way to make virtualenv work in shared Windows folders? I edit my code on my Windows machine which is why I use shared folders.
Thanks.
The virtualenv does not need to be located next to your code, so even if you can't create it within your shared folder this shouldn't affect your ability to edit the code on windows and run it on your host platform. It sounds to me like a bad idea anyway to attempt to share platform-specific files with multiple platforms.
This is the usefulness of the .pth files and if you're using setuptools with a setup.py within your project you can just $VENV/python setup.py develop which will link your project into the virtualenv, wherever it may be located. You can then run $VENV/python and your package will be in the sys.path and available for import.