I am following these steps to setup a virtual environment in Ubuntu 13.10 64-bit.
https://askubuntu.com/questions/244641/how-to-set-up-and-use-a-virtual-python-environment-in-ubuntu
After setting up the various things in bashrc and then on executing source .bashrc. I get the following traceback.
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
from stevedore import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/__init__.py", line 11, in <module>
from .extension import ExtensionManager
File "/usr/local/lib/python2.7/dist-packages/stevedore/extension.py", line 4, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2825, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 710, in subscribe
callback(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2825, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2257, in activate
self.insert_on(path)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2364, in insert_on
self.check_version_conflict()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2403, in check_version_conflict
for modname in self._get_metadata('top_level.txt'):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2251, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1219, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1211, in get_metadata
return self._get(self._fn(self.egg_info,name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1326, in _get
stream = open(path, 'rb')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.2-py2.7.egg/EGG-INFO/top_level.txt'
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
It seems that it is unable to find the installation of python. I too am puzzled bacause on executing "which python", I get /usr/bin/python but when I got /usr/bin, I am unable to find the python directory .Please help...
Thanks.
Permission denied seems like u need to be root to do that. Maybe you should use "sudo" before using the command which gives you the error
Did you install virtualenvwrapper? If yes, then sudo like mentioned by user2270433. If no, then install that and proceed with the instructions. I haven't used virtualenvwrapper, but the standard steps for virtualenv in my bootstraps are like this...
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo -n python ez_setup.py && sudo python get-pip.py
sudo -n pip install virtualenv
Related
I am using pyinstaller on CentOS 7 to convert a .py file to an executable. I am on python3.7.6
I have done:
$python3.7 -m pip install pyinstaller
$pyinstaller test.py --onefile
This gives me:
8942 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/root/test.spec", line 19, in <module>
noarchive=False)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 294, in __init__
self.__postinit__()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 540, in assemble
self._check_python_library(self.binaries)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 645, in _check_python_library
python_lib = bindepend.get_python_library_path()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/depend/bindepend.py", line 967, in get_python_library_path
raise IOError(msg)
OSError: Python library not found: libpython3.7.so, libpython3.7.so.1.0, libpython3.7mu.so.1.0, libpython3.7m.so, libpython3.7m.so.1.0
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
As pointed out here I have tried:
$env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.6
I have also installed python-devel:
$yum install python36-gobject-devel.x86_64
$yum install python3-devel.x86_64
$yum install python34-devel.x86_64
I am not sure what am I missing here. Any help will be appreciated.
I've tried to create an executable of my python script with pyinstaller, but it's not working.
If I run the exe file from terminal, I get these errors:
Traceback (most recent call last):
File "main.py", line 127, in <module>
File "main.py", line 9, in main
File "c:\users\danie\onedrive - universitat de valencia\escritorio\professors banda\profs\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "docx2pdf\__init__.py", line 13, in <module>
File "importlib\metadata.py", line 531, in version
File "importlib\metadata.py", line 504, in distribution
File "importlib\metadata.py", line 177, in from_name
importlib.metadata.PackageNotFoundError: docx2pdf
[13776] Failed to execute script main
I installed pyinstaller using pip inside the virtual environment of the project.
I would appreciate any help.
Thank you in advance.
Seems you have missing modules, that weren't found by PyInstaller analysis hooks.
Try to rebuild your application with --hidden-import=docx2pdf option.
I have installed pyforest with :
pip install --upgrade pyforest
It worked well, but when I run on terminal :
python -m pyforest install_extensions
I have this output :
Starting to install pyforest extensions for Jupyter Notebook and Jupyter Lab
Trying to install pyforest nbextension...
Traceback (most recent call last):
File "/home/bled/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/bled/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/bled/anaconda3/lib/python3.7/site-packages/pyforest/main.py", line 15, in
install_extensions()
File "/home/bled/anaconda3/lib/python3.7/site-packages/pyforest/utils.py", line 19, in install_extensions
install_nbextension()
File "/home/bled/anaconda3/lib/python3.7/site-packages/pyforest/utils.py", line 38, in install_nbextension
nbextensions.install_nbextension_python("pyforest")
File "/home/bled/anaconda3/lib/python3.7/site-packages/notebook/nbextensions.py", line 225, in install_nbextension_python
destination=dest, logger=logger
File "/home/bled/anaconda3/lib/python3.7/site-packages/notebook/nbextensions.py", line 126, in install_nbextension
ensure_dir_exists(nbext)
File "/home/bled/anaconda3/lib/python3.7/site-packages/jupyter_core/utils/init.py", line 13, in ensure_dir_exists
os.makedirs(path, mode=mode)
File "/home/bled/anaconda3/lib/python3.7/os.py", line 211, in makedirs
makedirs(head, exist_ok=exist_ok)
File "/home/bled/anaconda3/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/share/jupyter'
I have tried :
python -m pyforest install_extensions --user
But it doesn't work either and instead gives the following output:
Usage: python -m pyforest install_extensions installs notebook/lab
extensions
Can somone please help?
'python -m pyforest install_extensions' run this command on anaconda prompt not on terminal. There is another way we can install the extensions directly from jupyter notebook. These are the commands to follow
import pyforest
pyforest.install_nbextension()
pyforest.install_labextension()
When I run the command python -m virtualenv venv
I get the following output:
Traceback (most recent call last):
File "runpy.py", line 184, in _run_module_as_main
File "runpy.py", line 85, in _run_code
File "C:\python\lib\site-packages\virtualenv.py", line 2328, in <module>main()
File "C:\python\lib\site-packages\virtualenv.py", line 713, in main symlink=option.symlink)
File "C:\python\lib\site-packages\virtualenv.py", line 925, in create_environment site_packages=site-packaged clear= clear, symlink=simlink
File "C:\python\lib\site-packages\virtualenv.py", line 1147, in install_python writefile(site_filename_dst, SITE_PY)
File "C:\python\lib\site-packages\virtualenv.py", line 362, in writefile with open(dest, 'wb') as F:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\python\\sites\\venv\\python35.zip\\site.py'
When I navigate to the 'venv' folder the file structure is completely unpopulated with only C:\Python\sites\venv\Lib\site-packages (which is completely empty)
I have tried re-installing virtualenv and googling the issue with no avail. Please advise
Have you correctly installed the python on your machine? I also run into a similar issue earlier. It was caused by my python installation.
You see if you check your python path and go to the Lib folder, I assume there was no site.py. You can:
reinstalled your python, make sure it has correctly installed (check the Lib and Script folder)
correct your python path to your user/system environment: I assume you are using Window OSX, e.g: setx PYTHONHOME "C:\<your_python_path>"; add that to your path: setx PATH "%PATH%;%PYTHONHOME%"
Don't forget to add the Script path as well, if you want to access pip without python -m
Cheers!!
I have freshly installed Python 3.3 (x64) and PyWin32, and then did the following (mindeningyen-env is the directory of the virtualenv, mindeningyen is the name of the app):
distribute_setup.py
easy_install virtualenv
virtualenv --no-site-packages mindeningyen-env
cd mindeningyen-env
Scripts\activate
easy_install pyramid
pcreate -s alchemy mindeningyen
cd mindeningyen
setup.py develop
pip install waitress
And then I get the following trace:
(mindeningyen-env) D:\prg\mindeningyen-env\mindeningyen>pserve development.ini
Traceback (most recent call last):
File "d:\prg\mindeningyen-env\Scripts\pserve-script.py", line 9, in <module>
load_entry_point('pyramid==1.4', 'console_scripts', 'pserve')()
File "d:\prg\mindeningyen-env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\scripts\pserve.py", line 50, in main
return command.run()
File "d:\prg\mindeningyen-env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\scripts\pserve.py", line 304, in run
global_conf=vars)
File "d:\prg\mindeningyen-env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\scripts\pserve.py", line 328, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 454, in get_context
section)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 476, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 620, in get_context
object_type, name=name)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 640, in find_egg_entry_point
pkg_resources.require(self.spec)
File "d:\prg\mindeningyen-env\lib\site-packages\distribute-0.6.31-py3.3.egg\pkg_resources.py", line 706, in require
needed = self.resolve(parse_requirements(requirements))
File "d:\prg\mindeningyen-env\lib\site-packages\distribute-0.6.31-py3.3.egg\pkg_resources.py", line 604, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: mindeningyen
Any ideas why it doesn't find the project?
Using the new Python 3.3 native virtual env implementation, I can use Pyramid on Python 3.3 just fine:
python3.3 -m venv mindeningyen-env
cd mindeningyen-env/
source bin/activate
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
bin/easy_install pyramid
bin/pcreate -s alchemy mindeningyen
cd mindeningyen
python setup.py develop
cd ..
bin/pserve mindeningyen/development.ini
If using virtualenv (either installed, or python builtin), one shouldn't say things like
setup.py develop, because that will use the python interpreter, which is found in registry. One should ensure the virtualenv is activated Scripts\activate, and after that every python run should use python, so, the correct form is:
python setup.py develop