python can't use virtualenv - python

i'm running Python 2.7 with my debian testing and i've a probleme using virtualenv.
Im trying to create a virtualenv on a partition which is mount like
/dev/sda5 /media/misc vfat users,defaults,uid=1000,gid=1000,exec,umask=0 0 0
So, rights seems ok but virtualenv returns me :
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 3, in <module>
virtualenv.main()
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main
never_download=options.never_download)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1039, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1186, in install_python
copyfile(join(stdlib_dir, fn), join(lib_dir, fn))
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 430, in copyfile
copyfileordir(src, dest)
File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 405, in copyfileordir
shutil.copytree(src, dest, True)
File "/usr/lib/python2.7/shutil.py", line 206, in copytree
raise Error, errors
shutil.Error: [('/usr/lib/python2.7/config/libpython2.7.so', 'seb/lib/python2.7/config /libpython2.7.so', '[Errno 1] Operation not permitted')]
i've installed virtualenv with apt.
using virtualenv in my /home is successfull
can you help me ?

fixed. I don't exactly why, but i've formated my partiton with a ntfs type resolves the issue.
It seems that fat32 system adds control over fstab

Related

getting gmsh into the virtualenv

I'm extremely new to Python, so sorry if this is a stupid question. Anyways, I'm getting this error when trying to run a package I installed on PyCharm (Python IDE):
Traceback (most recent call last):
File "C:\Users\turtl\PycharmProjects\untitled\venv\Scripts\openbte-script.py", line 11, in <module>
load_entry_point('openbte==0.9.24', 'console_scripts', 'openbte')()
File "C:\Users\turtl\PycharmProjects\untitled\venv\lib\site-packages\openbte\__main__.py", line 47, in main
Geometry(**vars(args))
File "C:\Users\turtl\PycharmProjects\untitled\venv\lib\site-packages\openbte\geometry.py", line 83, in __init__
data = self.compute_mesh_data()
File "C:\Users\turtl\PycharmProjects\untitled\venv\lib\site-packages\openbte\geometry.py", line 91, in compute_mesh_data
self.import_mesh()
File "C:\Users\turtl\PycharmProjects\untitled\venv\lib\site-packages\openbte\geometry.py", line 448, in import_mesh
a=subprocess.check_output(['gmsh','-' + str(self.dim),'mesh.geo','-o','mesh.msh'])
File "C:\Users\turtl\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 336, in check_output
**kwargs).stdout
File "C:\Users\turtl\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 403, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\turtl\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Users\turtl\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
From what I've gathered from previous questions, it seems this is because I don't have gmsh in my virtualenv. Now that I've downloaded gmsh, I can't find a proper installation guide on how to get it into the virtualenv. Does anyone have experience with this?
I guess more specifically, is there a way I can pinpoint the path that it's trying to access and just paste gmsh into that directory?
openbte\geometry.py seems to run gmsh.exe without any path:
a=subprocess.check_output(['gmsh','-' + str(self.dim),'mesh.geo','-o','mesh.msh'])
Which means it expects gmsh.exe somewhere in the %PATH%. So install gmsh and add the directory with gmsh.exe to the %PATH%.

Permission Denied while trying to run a Python package

I'm trying to use a Python package called csvkit on an AWS EC2 machine. I was able to install it after some hiccups, which might be related - running pip install csvkit threw an error at
with open(path, 'rb') as stream:
IOERROR: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/requires.txt'
But I was able to install it with some other command.
Now onto the original problem - when I try to run a simple function within the csvkit package like cavstat, this is the full error output:
[username ~]$ csvstat
Traceback (most recent call last):
File "/usr/local/bin/csvstat", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3020, in <module>
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 614, in _build_master
ws.require(__requires__)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 920, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 815, in resolve
new_requirements = dist.requires(req.extras)[::-1]
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2552, in requires
dm = self._dep_map
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2537, in _dep_map
for extra, reqs in split_sections(self._get_metadata(name)):
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2978, in split_sections
for line in yield_lines(s):
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2252, in yield_lines
for ss in strs:
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2566, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1589, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1581, in get_metadata
return self._get(self._fn(self.egg_info, name))
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1692, in _get
with open(path, 'rb') as stream:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/python_dateutil-2.2-py2.7.egg/EGG-INFO/requires.txt'
I'm not sure what to even search to see what's the issue. Is this related to date-utils?
I'm fairly new to the Linux world, so editing configuration files and whatnot is a bit difficult for me.
If you're doing a system-wide install via 'pip install csvkit', you'll need sudo privileges for the current user, which is why the install process has borked on modifying the /usr/local/lib/python2.7 structure.
If you're on an AWS instance you've created, sudo privileges should be pretty straightforward to set up for your current user.
If you're looking for a more contained alternative, you could install virtualenv and set up an isolated virtualenv (https://virtualenv.pypa.io/en/latest/installation.html) but virtualenv might be overkill for a throwaway server.
Does that help at all?

Python traceback points to non-existent file

I'm trying to run a setup.py script (for mnemosyne). The script fails, and I'm pretty sure I know how to fix the problem, if I could only find the file to edit. The problem is that the traceback points to a non-existent file:
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
I believe that should be loader_path. The problem is that MachOGraph.py file doesn't exist -- not anywhere in my current path, or in my anaconda distribution. There is a build/bdist.macosx-10.5-x86_64/ directory, but no egg. There are a few MachOGraph.py files on my system, but none of them have that line. Nothing under this directory contains the string loader.filename.
What's going on? How can I find that file?
For completeness, here is the complete traceback:
Traceback (most recent call last):
File "/Users/mike/.continuum/anaconda/lib/python2.7/site-packages/ipdb/__main__.py", line 157, in main
pdb._runscript(mainpyfile)
File "/Users/mike/.continuum/anaconda/lib/python2.7/pdb.py", line 1233, in _runscript
self.run(statement)
File "/Users/mike/.continuum/anaconda/lib/python2.7/bdb.py", line 400, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "setup.py", line 241, in <module>
app = py2app_app
File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/Users/mike/.continuum/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 654, in run
self._run()
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 860, in _run
self.run_normal()
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 950, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg/py2app/build_app.py", line 1110, in create_binaries
platfiles = mm.run()
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "build/bdist.macosx-10.5-x86_64/egg/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
This issue is caused by Pillow, you can use pip uninstall Pillow to uninstall it, then this question will disappear.
Python takes the filename as reported in the bytecode when printing a traceback. In this case, the bytecode contains filenames that are generated to produce a Python egg, a format that contains at least the bytecode files. These paths reflect the build directory relative to the package as it was built.
In this case, it is the py2app installer that includes macholib as a installation requirement; setuptools downloads the source code for that library and produces an egg on demand, in the same location as the py2app egg. I'd look in /usr/local/src/Mnemosyne-2.3.1/py2app-0.8.1-py2.7.egg for a macholib-1.6-py2.7.egg directory.
With macholib1.7, from line 46 of **/MachOGraph.py...:
try:
fn = dyld_find(filename, env=self.env,
executable_path=self.executable_path,
loader=loader.filename)
self.trans_table[(loader.filename, filename)] = fn
except ValueError:
return None
Change line 49 to:
loader_path=loader.filename)

Can't create virtualenv with jython 2.7b2 as an interpreter

I want to execute some Java code from Python so I've decided to install standard python interpreter, jython and join them together using pyro4. Pyro4 requires python > 2.5 so I choose to use jython 2.7b. Here are steps I made to make this happen:
wget -i jython-installer-2.7-b2.jar http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7-b1/jython-installer-2.7-b2.jar
java -jar jython-installer-2.7-b2.jar
jython2.7b2/bin/virtualenv-2.7 oscar
And this is what I'm getting back:
Cannot find file /home/mnowotka/jython2.7b2/Include (bad symlink)
New jython executable in oscar/bin/jython
Installing setuptools.................
Complete output from command /home/mnowotka/oscar/bin/jython -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" /home/mnowotka/jytho...ols-0.6c11-py2.7.egg:
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
File "<string>", line 278, in <module>
File "<string>", line 210, in main
File "<string>", line 161, in download_setuptools
File "/home/mnowotka/jython2.7b2/Lib/socket.py", line 1651, in read
data = self._sock.recv(recv_size)
File "/home/mnowotka/jython2.7b2/Lib/httplib.py", line 567, in read
s = self.fp.read(amt)
File "/home/mnowotka/jython2.7b2/Lib/socket.py", line 1669, in read
data = self._sock.recv(recv_size)
File "/home/mnowotka/jython2.7b2/Lib/socket.py", line 174, in handle_exception
raise _map_exception(jlx)
socket.error: [Errno 32] Socket closed
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "jython2.7b2/bin/virtualenv-2.7", line 3, in <module>
virtualenv.main()
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 970, in main
create_environment(home_dir,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 1090, in create_environment
install_setuptools(py_executable, unzip=unzip_setuptools,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 610, in install_setuptools
_install_req(py_executable, unzip,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 579, in _install_req
call_subprocess(cmd, show_stdout=False,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 1055, in call_subprocess
raise OSError(
OSError: Command /home/mnowotka/oscar/bin/jython -c "#!python
\"\"\"Bootstra...sys.argv[1:])
Does it mean that jython 2.7b2 is not quite ready yet or I'm doing something wrong?
Use this ez_setup.py to install setuptools:
added setuptools-egg and md5

Virtualenv: can't create virtualenv: IOError: [Errno 2] No such file or directory: 'python'

This happens when attempting to update the python installation in my virtualenv OR when creating a new virtualenv:
[marcintustin#localhost oneclickrep]$ virtualenv --always-copy --clear --python=/usr/bin/python oneclickcosvirt/
Already using interpreter /usr/bin/python
Deleting tree oneclickcosvirt/lib/python2.7
Not deleting oneclickcosvirt/bin
New python executable in oneclickcosvirt/bin/python
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.10.1', 'console_scripts', 'virtualenv')()
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 821, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 956, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1377, in install_python
shutil.copyfile(py_executable_base, full_pth)
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'python'
[marcintustin#localhost oneclickrep]$
The result is consistently the above. /usr/bin/python exists and is working very nicely (it's also the python picked up by which). What's the cause here?
Edit: Using virtualenv version 1.10.1
This is a bug with virtualenv. Using the --always-copy flag triggers copying behaviour, which is broken. There are bug reports and patches already submitted.
The line shutil.copyfile(py_executable_base, full_pth) should be shutil.copyfile(py_executable, full_pth).

Categories