Issue following AWS elastic beanstalk flask virtual enviorment - python

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.

Related

Why can't Python find the module I installed?

Presently I'm using Python on a Windows system. I installed Python 3.10 from Anaconda and also the Pycharm IDE. I have ensured that Python is in the correct path in the environment variable. I have also replicated this problem using two different versions of Python, 3.10 and 3.9.
Very simply, in PyCharm, I open a terminal and type
conda install -c numpy numpy.
Then, I write a new "main.py" script. I have one line: "import numpy". I receive the error:
Traceback (most recent call last):
File "C:\Users\---\PycharmProjects\pythonProject3\main.py", line 17, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
What am I doing wrong?
Going on advice from a friend, I created a new PyCharm project sitting not in my user directory but on the C: drive, and got the same error. Finally, when trying to re-install the package using either using either pip or conda, I get this message:
# All requested packages already installed.
You have 2 versions of Python:
Default Python (used everytime you open your command prompt and type python or python3)
Anaconda is installing packages in a virtual environment, using it's own Python (it is located in a different path)
You can see the path of your installed python using python -c "import os, sys; print(os.path.dirname(sys.executable))"
You have 2 Options:
Configure the PyCharm in order to use the anaconda Python. https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#view_list
Open a command prompt in the project's folder (you can do it easily using PyCharm). Type conda env list. This will show you all available anaconda virtual environments. Choose 1 of them and type conda activate <env_name>, where <env_name>=the name of the environment. Then, run your program using python <name_of_your_program>
You can see the paths where the anaconda environments and packages are installed using conda info
There main reason for this is
You are running your main.py in different environment rather than where you installed numpy.
If you trying to run it via cmd use this method
Check which environment you are in right now. refer this and
this. But the most easiest way to do this is use where command
in windows cmd. C:\> where python or C:\> where python3. You will
get the path of activated interpreter.
list conda envs - conda env list
activate conda env - conda activate <env name>
then run this command. pip freeze . and check is there numpy in
the list. If not you have to find and activate the environment where
you have installed numpy.
If you want to run it in pycharm
Refer this on how to change pycharm interpreter.
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html
Many things can cause this, usually its one of these
You may have to restart your terminal, or IDE if running in there, after installing a package to "refresh" the environmental path
The package is not in the environmental path

i am trying to create a virtual environment in python but I get the error: failed to find interpreter for Builtin discover of python_spec=python3.5

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.

`dyld: Library not loaded` error preventing virtualenv from loading

When I tried creating a virtual environment with python using the command virtualenv venv from Terminal, I got the following error:
Using base prefix '/Users/zacharythomas/anaconda3'
New python executable in /Users/zacharythomas/venv/bin/python
dyld: Library not loaded: #rpath/libpython3.6m.dylib
Referenced from: /Users/zacharythomas/venv/bin/python
Reason: image not found
ERROR: The executable /Users/zacharythomas/venv/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/zacharythomas' (should be '/Users/zacharythomas/venv')
ERROR: virtualenv is not compatible with this system or executable
I'm not the first person to encounter a similar error -- I tried following this answer's recommendations and running:
gfind ~/.virtualenvs/my-virtual-env/ -type l -xtype l -delete
That didn't help. Nor did running sudo virtualenv venv to run commmand as a super user.
What should I investigate next?
I had the exact same error message. Ray Donnelly at Continuum Analytics Support Group provided the following solution, which resolved the issue for me:
When you pip installed virtualenvwrapper, pip will have installed
virtualenv for you as it is a dependency. Unfortunately, that
virtualenv is not compatible with Anaconda Python. Fortunately, the
Anaconda Distribution has a virtualenv that is compatible. To fix
this:
pip uninstall virtualenv
conda install virtualenv
can't get virtualenv to work with anaconda3 v4.3 on mac

virtualenv doesn't work in mac with anaconda

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.

how to make virtualenv with another interpreter?

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

Categories

Resources