juldou#juldou-machine:~/Programovanie/Python/Projects/project_sql$ /usr/local/lib/python3.5/site-packages/virtualenv project_sql
Output of the command above:
Using base prefix '/home/juldou/anaconda3'
New python executable in /home/juldou/Programovanie/Python/Projects/project_sql/project_sql/bin/python
/home/juldou/Programovanie/Python/Projects/project_sql/project_sql/bin/python: error while loading shared libraries: libpython3.5m.so.1.0:cannot open shared object file: No such file or directory
ERROR: The executable /home/juldou/Programovanie/Python/Projects/project_sql/project_sql/bin/python is not functioning
ERROR: It thinks sys.prefix is '/home/juldou/Programovanie/Python/Projects/project_sql' (should be '/home/juldou/Programovanie/Python/Projects/project_sql/project_sql')
ERROR: virtualenv is not compatible with this system or executable
I want to use my python3.4 interpeter. How to make virtualenv with this interpreter?
First install virtualenv,
then
virtualenv -p python3 envname
Now you have a venv with python3 interpreter
Related
Morining All,
i am trying to create a virtual environment in Python with virtualenv, I'm using the command:
virtualenv -p python3.5 MyVirtualEnv
but I get the error:
RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.5'
Now on my Mac (with M1 chip) I have Python 3.8 but I need a virtual environment because I have to use the ZS library that runs only in older python version.
You don't need to install python 3.5 in your virtualenv instead install it on your system and then set it as a Project SDK which will install itself all required things in /venv folder.
I'm trying to follow the instruction here and have issues with step one:
Create a virtual environment named eb-virt:
~$ virtualenv ~/eb-virt
dyn-160-39-133-189:~ me$ cd ~
dyn-160-39-133-189:~ me$ virtualenv ~/eb-virt
Using base prefix '/Users/me/anaconda'
New python executable in /Users/me/eb-virt/bin/python
ERROR: The executable /Users/me/eb-virt/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/me' (should be '/Users/me/eb-virt')
ERROR: virtualenv is not compatible with this system or executable
I saw that the anaconda package is being used:
which python
/Users/me/anaconda/bin/python
Which might be the issue so I tried:
alias python=/usr/local/bin/python2.7
which gave me both:
python -V
-bash: /usr/local/bin/python2.7: No such file or directory
and
which python
/Users/me/anaconda/bin/python
I usually use conda (new to python but it seems to work well) so I'm not sure if the issue lies with conda or something else.
I have virtualenv installed and also 2 versions of python installed. One is through homebrew another is in anaconda. But virtualenv doesn't work with either of them. I found some posts saying this is due to messy python version. But even I point to different python, it still doesn't work. Is there any solution for this ? Thanks
jzhangMBPr:~ jzhang$ virtualenv -p /Users/jzhang/anaconda/bin/python a
Already using interpreter /Users/jzhang/anaconda/bin/python
Using base prefix '/Users/jzhang/anaconda'
New python executable in /Users/jzhang/a/bin/python
ERROR: The executable /Users/jzhang/a/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/jzhang' (should be '/Users/jzhang/a')
ERROR: virtualenv is not compatible with this system or executable
jzhangMBPr:~ jzhang$ virtualenv a
Using base prefix '/Users/jzhang/anaconda'
New python executable in /Users/jzhang/a/bin/python
ERROR: The executable /Users/jzhang/a/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/jzhang' (should be '/Users/jzhang/a')
ERROR: virtualenv is not compatible with this system or executable
You probably pointing virtualenv to the wrong Python installation. I thought its regardless of which python interpreter you have. Virtualenv comes with a -p flag which let you specifically which interpreter in use.
Use;
virtualenv -p python test
Instead;
virtualenv test
Also you can use virtualenv -h, which appears an help documentation for usage of other specific virtualenv flags.
Please check your conda init. For me running :
conda init bash
solved the problem.
I can install pysvn site-wide using the binary package. For example, in Ubuntu:
$ sudo apt-get install python-svn
Or, on Windows, I can install site-wide using the .exe installer.
Outside of a virtualenv, I can do this
$ python -c "import pysvn; print 'ok'"
ok
Now I make a virtualenv (I use the mkvirtualenv command from the virtualenvwrapper package)
$ mkvirtualenv test1
But since virtualenv defaults to not importing global site packages, I can not use pysvn inside this virtualenv.
(test1)$ python -c "import pysvn; print 'ok'"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pysvn
How do I access pysvn in a virtualenv without enabling global site packages?
There are a number of ways to handle this.
Option 0
Allow access to the global site packages from within the virtualenv. Pass the --system-site-packages option to virtualenv when creating the virtual environment.
Or, use the toggleglobalsitepackages command (from virtualenvwrapper) to allow access to global site packages.
(test1)$ toggleglobalsitepackages
Enabled global site-packages
(test1)$ python -c "import pysvn; print 'ok'"
ok
(test1)$ toggleglobalsitepackages
Disabled global site-packages
(test1)$ python -c "import pysvn; print 'ok'"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pysvn
Option 1
Use easy_install to install the package in to the virtualenv using a binary installer. For example, on Windows the process might look like this:
Download the binary installer file. In this example, let's call it example_installer.msi (or example_installer.exe)
Activate the virtualenv (I use virtualenvwrapper-win on Windows)
easy_install example_installer.msi
Verify that you can install the installer site-wide, by double-clicking and running the installer in gui mode (then uninstal using the Windows Add/Remove Programs control panel). If you can install it site-wide, then easy_install can probably install it in to a virtualenv.
However, the pysvn binary installer is not structured properly for easy_install. If you try this with the Windows pysvn binary installer you get this error:
error: py27-pysvn-svn185-1.7.9-1572.exe is not a valid distutils Windows .exe
Option 2
Use the add2virtualenv command from virtualenvwrapper. This adds a .pth file to the virtualenv's site-packages directory, which gives the virtualenv access to the specified directories.
Note that you must specify the parent directory, instead of the specific package. That is, instead of
add2virtualenv /usr/lib/python2.7/dist-packages/pysvn
It should be
add2virtualenv /usr/lib/python2.7/dist-packages
See this question: add2virtualenv (virtualenv wrapper) does not work with scipy
To find the directory where a package is installed, do this:
$ python
>>> import pysvn
>>> pysvn.__file__
'/usr/lib/python2.7/dist-packages/pysvn/__init__.pyc'
The problem is, this includes all the packages in the specified directory, not just pysvn. So, it has the same drawback as toggleglobalsitepackages.
Option 3
Symlink the install directory in to the virtualenv's site-packages.
A convenient way to get to the virtualenv's site-packages directory is to use virtualenvwrapper's cdsitepackages command
cdsitepackages
ln -s /usr/lib/python2.7/dist-packages/pysvn pysvn
Summary
On Windows, try Option 1 (easy_install from binary installer). If that fails, install globally and allow the virtualenv to access it by using virtualenvwrapper-win's toggleglobalsitepackages command, or by passing the --system-site-packages option to virtualenv.
On systems that support symlinking, such as Linux and OS X, use Option 3. It allows you to access the specific packages you need without allowing access to the whole global site packages.
I'm on a mac, which comes with python 2.7 installed, so I should have the required version.
At least, I believe that's the problem. I'm getting an error when trying to run make install for a project, and getting the following error:
The executable python2 (from --python=python2) does not exist
make: *** [bin/python] Error 3
virtualenv --python=python3 fibonacci_env
Point out which python
Specify the full path to the Python interpreter (not sure if this is the right path - haven't used MacOs):
mkvirtualenv myenv --python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python
or smth like:
--python=$(which python)
Python 2.7 is part of system framework and is located here:
/System/Library/Frameworks/Python.framework/Versions/
If you want to create a virtualenv with python2.7 on macOS Sierra do this:
virtualenv -p /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python my_venv
Specify the python version you want to use
virtualenv -p /usr/bin/python3 venv