Error installing pyv8 on virtualenv on Windows - python

I'm trying to install the pyv8 package on a virtualenv on Windows.
Here is what I did:
virtualenv venv
venv\Scripts\activate
pip install pyv8
and the last command failed with the following error:
File "<string>", line 17, in <module>
File "<proj_path>\venv\build\pyv8\setup.py", line 17, in <module>
include_dirs += os.environ["INCLUDE"].split(';')
File "<proj_path>\venv\lib\os.py", line 423, in __getitem__
return self.data[key.upper()]
KeyError: 'INCLUDE'
What am I missing?

There is actually an executable that installs it for you on windows.
When you install it, be sure to point the installation directory to your virtualenv directory. You might also want to check out this repeat

Related

pip2: ImportError: cannot import name RequirementParseError

I can't get pip2 to work.
I need pip2, because I need to use an older tensorflow version which is not supported by python3 pip. When trying to run pip2 install I get this:
Traceback (most recent call last):
File "/usr/bin/pip2", line 11, in <module>
load_entry_point('pip==20.1.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python2.7/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 21, in <module>
from pip._internal.req.constructors import (
File "/usr/lib/python2.7/site-packages/pip/_internal/req/constructors.py", line 21, in <module>
from pip._vendor.pkg_resources import RequirementParseError, parse_requirements
ImportError: cannot import name RequirementParseError
I uninstalled pip2 and reinstalled it. Also did the same for pip(3). But this didn't change a thing. I could not find anything useful on this error message and feel a bit helpless. Any ideas?
update forgot to mention, that I use archlinux. I installed it with pacman -S python2-pip
Did you try installing packages using virtualenv ? pacman ? or using only pip ?
Which version of tensorflow are you trying to install ?
You can try install libraries using a recent pip2 version + virtualenv using the following commands:
pacman -S python2 python2-pip python-virtualenv
virtualenv -p python2 py2
. py2/bin/activate
pip install -U pip setuptools wheel
pip install tensorflow ipython
You may also try uninstall python2 first and reinstall it from scratch:
pacman -Rs python2 python2-pip
This link suggests that the problem might be due to a version of setuptools installed in ~/.local . Maybe you can check that.
Nevermind, setuptools was installed in my ~/.local directory for some
reason, superceding the system install, I removed that and pip2 runs
fine now.
Please see this link:
https://askubuntu.com/questions/984868/error-in-installing-sudo-pip-install-v-protobuf-3-0-0a2
The library is different but the error is the same.

Unable to install pip with "python get-pip.py --user"

I'm unable to install pip using python setup.py --user, and I think my python install is generally a bit foobared.
I want to be able to use pip without sudo on my user (vagrant in this case). Everything I've read indicates that the above should work, but it just refuses to.
If I use sudo python setup.py --user then it installs correctly, but again, the sudo shouldn't be necessary because of the installation to the user directory.
python setup.py --user
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from setuptools import find_packages, setup
File "/home/vagrant/.local/lib/python3.6/site-packages/setuptools/__init__.py", line 16, in <module>
import setuptools.version
File "/home/vagrant/.local/lib/python3.6/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3126, in <module>
#_call_aside
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3110, in _call_aside
f(*args, **kwargs)
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3139, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 572, in _build_master
ws = cls()
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 565, in __init__
self.add_entry(entry)
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 621, in add_entry
for dist in find_distributions(entry, True):
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1968, in find_on_path
for dist in factory(fullpath):
File "/home/vagrant/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2030, in distributions_from_metadata
if len(os.listdir(path)) == 0:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/websocket_client-0.54.0.dist-info'
Other bits of info...
python -V
Python 3.6.7
which python
/usr/bin/python
Also, I know that I can use a venv to achieve what I want, but the point is it should work, and doesn't, which a) bugs me to no end, and b) indicates that something is just plain wrong with my setup.
It looks to me as if you are trying to install stuff to the system Python using a non root user and hence do not have permissions to edit stuff in the system's site-packages. Please can you run a whoami and see which user you are logged in as, if you are logged in as someone other than root you should use sudo to install packages into the system's Python, e.g. sudo pip install my_package.
If you do not want to install packages to the system's Python site-packages directory then you probably should be operating in a virtualenv, this gives you a self contained Python env for your project and can be created as any user in their home directory.
To get virtualenv installed:
sudo pip install virtualenv
Then to create a new virtualenv as the user:
virtualenv my_env
Assume / Activate the virtualenv:
source my_env/bin/activate
Now you can install packages using pip as your user into your Python virtualenv:
pip install my_package
This gives you a fully separate Python env running as your user from the system Python installation. Hopefully this helps you, if I have misunderstood your use case please leave a comment and I'll update my answer accordingly.

Unable to create virtual environment

I am unable to create virtual environment using both Python 2.x or Python 3.x. When I try create virtual environment I get error:
$ virtualenv my_env2 [0:05:17] ⚡[..........]
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/user/my_env2/bin/python2
Not overwriting existing python script /home/user/my_env2/bin/python (you must use /home/user/my_env2/bin/python2)
Installing setuptools, pkg_resources, pip, wheel...
Complete output from command /home/lynx/my_env2/bin/python2 - setuptools pkg_resources pip wheel:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/__init__.py", line 31, in <module>
File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/vcs/mercurial.py", line 9, in <module>
File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 40, in <module>
ImportError: cannot import name requests
----------------------------------------
...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/virtualenv.py", line 2375, in <module>
main()
File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main
symlink=options.symlink)
File "/usr/lib/python3/dist-packages/virtualenv.py", line 992, in create_environment
download=download,
File "/usr/lib/python3/dist-packages/virtualenv.py", line 922, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/usr/lib/python3/dist-packages/virtualenv.py", line 817, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/user/my_env2/bin/python2 - setuptools pkg_resources pip wheel failed with error code 1
The same error occurs for Python 3.x. Can you help me?
I had a similar problem when trying to do this with Python3. Try this command:
sudo python3 -m <your virtual env name>
First, make a directory of any name :
mkdir testing
Then, moved to this newly created directory named testing :
cd testing
When you type following command in this directory:
python3 -m venv env
You got error like :
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.8-venv
Type the following command but before that keep an eye on the version of python you installed on the machine; in my case its python3.8
sudo apt install python3.8-venv
Now, we can create a virtual environment and store its tools in the "bhandari" folder .
python3 -m venv bhandari
Note: you can named this "bhandari" folder; anyname you like( Standard practice is to name it "env" ...)
Now to activate your virtual environment, from the directory of your folder, type the following command this will activate our virtual environment in the “bhandari” folder
source bhandari/bin/activate
If you have successfully activated your virtual environment, you should see the (bhandari) word indicating that we are working in a virtual environment.
After this, we can install anything that will be isolated from the rest of the system....

Error when trying to run pip

My system is centos (linux). I have two Python versions, one is 2.7, the other is 3.6. I executed:
$ wget"https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb"# tar -xzvf pip-1.5.4.tar.gz
$ cd pip-1.5.4
$ python setup.py install
But, when I tried to use pip, I got an error:
File "/root/anaconda3/bin/pip", line 11, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/root/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 565, in load_entry_point
File "/root/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2598, in load_entry_point
File "/root/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2258, in load
File "/root/anaconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 2264, in resolve
File "/root/anaconda3/lib/python3.6/site-packages/pip-1.5.4-py3.6.egg/pip/__init__.py", line 9, in <module>
from pip.log import logger
File "/root/anaconda3/lib/python3.6/site-packages/pip-1.5.4-py3.6.egg/pip/log.py", line 9, in <module>
from pip._vendor import colorama, pkg_resources
File "/root/anaconda3/lib/python3.6/site-packages/pip-1.5.4-py3.6.egg/pip/_vendor/pkg_resources.py", line 1423, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
What can I do?
Use a virtualenv for specifying the version of python.
Virtualenvs help in solving library conflicts and it is good practice to use a different virtualEnv for every project.
Install virtualenv and virtualenvwrapper
pip install virtualenv
pip install virtualenvwrapper
Add to .zshrc or .bashrc:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/code
source /usr/local/bin/virtualenvwrapper.sh
Specify which Python to use with mkvirtualenv:
virtualenvwrapper lets you specify the python executable without the path:
mkvirtualenv -python=python3 myVirtualEnv
Run: workon
A list of environments, empty, is printed.
Run mkvirtualenv to create a new virtualenv: mkvirtualenv temp
A new environment, temp is created and activated.
Run: workon
This time, the temp environment is included.
workon temp to work on the new virtualenv
use pip to install packages inside the virtualenv
After you're done using the virtualenv, simply deactivate out of it
(if you want to delete the virtualenv, use rmvirtualenv)
Use lssitepackages to list site-packages within the virtualenv.

mac osx: unable to use virtualenv

I'm trying to create an environment using virtualenv.
virtualenv test
New python executable in test/bin/python
Error [Errno 2] No such file or directory while executing command install_name_tool -change /System/Library/Fram.../Versions/2.6/Python #executable_path/../.Python test/bin/python
Could not call install_name_tool -- you must have Apple's development tools installed
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 810, in main
never_download=options.never_download)
File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 901, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 1166, in install_python
py_executable])
File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 843, in call_subprocess
cwd=cwd, env=env)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child
OSError: [Errno 2] No such file or directory
Folder is created alright, but files like activate are missing. Anyone? (I have xcode 3.2.3 installed. running python 2.6, osx 10.6.8)
Your developer tools are not installed correctly. I recommend installing Xcode 4.
I had the same error messages trying to run virtualenv on a up-to-date Max OS X Lion (10.7.2) installation with XCode installed and very up-to-date using the App Store.
I missed the /usr/bin/install_name_tool as well, however it is there in the system. Use the terminal in the following code blocks.
$ locate install_name_tool
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/install_name_tool
/Developer/usr/bin/install_name_tool
/Developer/usr/share/man/man1/install_name_tool.1
I made a simlink from the /Developer/usr/bin to the /usr/bin with
$ sudo ln -s /Developer/usr/bin/install_name_tool /usr/bin/install_name_tool
Entering the 'which' command yields:
$ which install_name_tool
/usr/bin/install_name_tool
After that I did the virtualenv magic
$ virtualenv -p python2.6 myvirtenv
Running virtualenv with interpreter /opt/local/bin/python2.6
New python executable in myvirtenv/bin/python
Installing setuptools............................done.
Installing pip...............done.
Works like a charm now!
Use install_name_tool from #gregglind's fork of virtualenv:
git clone https://github.com/gregglind/virtualenv.git
cd virtualenv
git checkout feature/install_name_tool
sudo python setup.py install
Credits: macdhuibh (https://github.com/pypa/virtualenv/issues/7)
Get the XCode Command line tools from here:
https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-#
I just fresh installed Lion, and installed XCode from the App Store - and these didn't get installed at the same time, need a separate install now I guess...

Categories

Resources