Creating a new virtual machine is not working - python

My goal is to work with Twitter API and do a sentiment analysize on tweets.
I am Working on a MAC, with VS Code on Anaconda.
I followed the tutorial and installed: python3 -m pip install --user virtualenv in my Terminal:
(base) Ludwigs-MBP:~ ludwigmehmke$ python3 -m pip install --user virtualenv
Requirement already satisfied: virtualenv in ./.local/lib/python3.7/site-packages (20.4.3)
Requirement already satisfied: six<2,>=1.9.0 in /opt/anaconda3/lib/python3.7/site-packages (from virtualenv) (1.12.0)
Requirement already satisfied: filelock<4,>=3.0.0 in /opt/anaconda3/lib/python3.7/site-packages (from virtualenv) (3.0.12)
Requirement already satisfied: distlib<1,>=0.3.1 in ./.local/lib/python3.7/site-packages (from virtualenv) (0.3.1)
Requirement already satisfied: appdirs<2,>=1.4.3 in ./.local/lib/python3.7/site-packages (from virtualenv) (1.4.4)
Requirement already satisfied: importlib-metadata>=0.12; python_version < "3.8" in /opt/anaconda3/lib/python3.7/site-packages (from virtualenv) (0.23)
Requirement already satisfied: zipp>=0.5 in /opt/anaconda3/lib/python3.7/site-packages (from importlib-metadata>=0.12; python_version < "3.8"->virtualenv) (0.6.0)
Requirement already satisfied: more-itertools in /opt/anaconda3/lib/python3.7/site-packages (from zipp>=0.5->importlib-metadata>=0.12; python_version < "3.8"->virtualenv) (7.2.0)
(base) Ludwigs-MBP:~ ludwigmehmke$
(base) Ludwigs-MBP:~ ludwigmehmke$
This is what I get. Next step was to create a Virtual Machine in VS Code. I entered the terminal there and created following code:
Ludwigs-MBP:Python ludwigmehmke$ python3 -m venv venv
Error: [Errno 1] Operation not permitted

Related

I cant install flask in my project i write pip install flask and when i write flask --version it doesn't recognize it?

pip install flask
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: flask in c:\users\muden\appdata\roaming\python\python310\site-packages (2.0.2)
Requirement already satisfied: click>=7.1.2 in c:\users\muden\appdata\roaming\python\python310\site-packages (from flask) (8.0.3)
Requirement already satisfied: itsdangerous>=2.0 in c:\users\muden\appdata\roaming\python\python310\site-packages (from flask) (2.0.1)
Requirement already satisfied: Jinja2>=3.0 in c:\users\muden\appdata\roaming\python\python310\site-packages (from flask) (3.0.3)
Requirement already satisfied: Werkzeug>=2.0 in c:\users\muden\appdata\roaming\python\python310\site-packages (from flask) (2.0.3)
Requirement already satisfied: colorama in c:\users\muden\appdata\roaming\python\python310\site-packages (from click>=7.1.2->flask) (0.4.4)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\muden\appdata\roaming\python\python310\site-packages (from Jinja2>=3.0->flask) (2.0.1)
What is the problem Pleaz?
can u try that after creating a virtual environment inside your folder,
steps to create virtual env and using it are here:
step 1:
python -m venv venv
step 2 for linux :
source venv/bin/activate
step 2 for windows :
source venv\Scripts\activate
step 3 : now install your projects requirement here and try running using flask it will work.
pip install flask
flask --version

I have installed IPython, and still "No module named 'IPython'"

My Python version:Python 3.8.3
python -m pip install IPython gives me Successfully installed IPython-7.18.1
Still gives me the following error:
from IPython.display import Image
/usr/bin/python3 "/home/sanyifeju/Desktop/python/ML/decision_trees.py"
Traceback (most recent call last):
File "/home/sanyifeju/Desktop/python/ML/decision_trees.py", line 4, in <module>
from IPython.display import Image
ModuleNotFoundError: No module named 'IPython'
'
What am I missing?
I am on Ubuntu 20.04.1 , not sure if that makes any difference.
if I run python -m pip install ipython
I get Requirement already satisfied.
Requirement already satisfied: ipython in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (7.18.1)
Requirement already satisfied: setuptools>=18.5 in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (49.6.0.post20200814)
Requirement already satisfied: decorator in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (4.4.2)
Requirement already satisfied: pexpect>4.3; sys_platform != "win32" in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (4.8.0)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (3.0.7)
Requirement already satisfied: jedi>=0.10 in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (0.17.1)
Requirement already satisfied: pygments in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (2.7.1)
Requirement already satisfied: backcall in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (0.2.0)
Requirement already satisfied: pickleshare in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (0.7.5)
Requirement already satisfied: traitlets>=4.2 in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from ipython) (4.3.3)
Requirement already satisfied: ptyprocess>=0.5 in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from pexpect>4.3; sys_platform != "win32"->ipython) (0.6.0)
Requirement already satisfied: wcwidth in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython) (0.2.5)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from jedi>=0.10->ipython) (0.7.0)
Requirement already satisfied: ipython-genutils in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from traitlets>=4.2->ipython) (0.2.0)
Requirement already satisfied: six in /home/sanyifeju/anaconda3/lib/python3.8/site-packages (from traitlets>=4.2->ipython) (1.15.0)
I had the same issue, and the problem was that the python command was linked to the python2 version:
$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 7 Apr 15 2020 /usr/bin/python -> python2*
The following commands fixed it for me:
$ sudo rm /usr/bin/python
$ sudo ln -s python3 /usr/bin/python
Try installing-
python -m pip install ipython

Transforming python code to HDL using hls4ml

I am following this tutorial: https://fastmachinelearning.org/hls4ml/setup/QUICKSTART.html
when I give the command:
root#ubuntu:~/Desktop/vivado/hls4ml/example-models$ hls4ml convert -c keras-config.yml
hls4ml: command not found
What should I do? I tried
pip install hls4ml
I get this:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: hls4ml in /home/mojito/.local/lib/python2.7/site-packages (0.2.0)
Requirement already satisfied: numpy in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (1.16.6)
Requirement already satisfied: six in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (1.14.0)
Requirement already satisfied: pyyaml in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (5.3.1)
Requirement already satisfied: h5py in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (2.10.0)
Requirement already satisfied: onnx>=1.4.0 in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (1.6.0)
Requirement already satisfied: typing>=3.6.4; python_version < "3.5" in /home/mojito/.local/lib/python2.7/site-packages (from onnx>=1.4.0->hls4ml) (3.7.4.1)
Requirement already satisfied: protobuf in /home/mojito/.local/lib/python2.7/site-packages (from onnx>=1.4.0->hls4ml) (3.11.3)
Requirement already satisfied: typing-extensions>=3.6.2.1 in /home/mojito/.local/lib/python2.7/site-packages (from onnx>=1.4.0->hls4ml) (3.7.4.1)
Requirement already satisfied: setuptools in /home/mojito/.local/lib/python2.7/site-packages (from protobuf->onnx>=1.4.0->hls4ml) (44.1.0)
Try this:
$ git clone https://github.com/hls-fpga-machine-learning/hls4ml.git
$ cd hls4ml/
$ pip install .
Git repo: https://github.com/hls-fpga-machine-learning/models .
Also you can use pip as a module: $ python -m pip <command> [options]

Python cannot see module after installing via pip

I'm still trying to master the science of installing packages via pip. When I run pip to install geocoder, I get the following:
(base) C:\Users\MBSanders>python -m pip install geocoder
Requirement already satisfied: geocoder in c:\programdata\anaconda3\lib\site-packages (1.38.1)
Requirement already satisfied: requests in c:\programdata\anaconda3\lib\site-packages (from geocoder) (2.21.0)
Requirement already satisfied: future in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.17.1)
Requirement already satisfied: click in c:\programdata\anaconda3\lib\site-packages (from geocoder) (7.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from geocoder) (1.12.0)
Requirement already satisfied: ratelim in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.1.6)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2019.3.9)
Requirement already satisfied: idna<2.9,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (3.0.4)
Requirement already satisfied: decorator in c:\programdata\anaconda3\lib\site-packages (from ratelim->geocoder) (4.4.0)
When I run
os.getcwd()
in spyder/python, I get
'C:\\Users\\MBSanders'
My question is, why do I get
ModuleNotFoundError: No module named 'geocoder'
When I run
import geocoder
I'm somewhat new to python. Please let me know if additional info is needed to trouble shoot. I'm within a federal agency so I do not have admin rights.
When I run sys.path in the console, I get
sys.path
Out[12]:
['F:\\Users\\MBSanders',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\python37.zip',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3',
'',
'C:\\Users\\MBSanders\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\IPython\\extensions',
'F:\\Users\\MBSanders\\.ipython']
Assuming you're running python on the terminal, and python is the command you're using to run it, try doing python -m pip install geocoder. That'll install it for the python build you want to use. Or if you know the full path to the python build you're using, you can do something similar like /path/to/python -m pip install geocoder.
if you are using python 3.7 or 3.8 you may need to pip3.7 or pip3.8 install if you OS is recognizing a 2.x version as default

I can't install Jupyter and Matplotlib in my anaconda env

I have an environment of Anaconda (apart of root) and I'm trying to install this two libraries with no success. I tried:
Install libraries by the environment tools of Anaconda Navigator with
'Multiple Errors Encountered.' error. Could I get more info about it? The options that I saw didn't say anything more.
'Multiple Errors Encountered.'
Install Jupyter with the install option of the apps of Anaconda Navigator with the same error too
'Multiple Errors Encountered.'
Install with conda install jupyter and conda install matplotlib in the console and cd where the environment is located. The console
made its process and it said that both libraries were already
installed. I check it in the libraries list of Anaconda Navigator and
it doesn't appear.
(base) C:\Users...>cd C:\Users\Alvaro\Anaconda3\envs\tensorflow
(base) C:\Users...\Anaconda3\envs\tensorflow>conda install
matplotlib Solving environment: done
All requested packages already installed.
(base) C:\Users\Alvaro\Anaconda3\envs\tensorflow>conda install jupyter
Solving environment: done
All requested packages already installed.
Install with pip install jupyter and pip install matplotlib with the similar result than conda install option.
(base) C:\Users\Alvaro\Anaconda3\envs\tensorflow>pip install jupyter Requirement already satisfied: jupyter in
c:\users\alvaro\anaconda3\lib\site-packages (1.0.0) Requirement
already satisfied: notebook in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (5.5.0)
Requirement already satisfied: qtconsole in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (4.3.1)
Requirement already satisfied: jupyter-console in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (5.2.0)
Requirement already satisfied: nbconvert in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (5.3.1)
Requirement already satisfied: ipykernel in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (4.8.2)
Requirement already satisfied: ipywidgets in
c:\users\alvaro\anaconda3\lib\site-packages (from jupyter) (7.2.1)
Requirement already satisfied: jupyter-client>=5.2.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(5.2.3) Requirement already satisfied: nbformat in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(4.4.0) Requirement already satisfied: ipython-genutils in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(0.2.0) Requirement already satisfied: Send2Trash in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(1.5.0) Requirement already satisfied: traitlets>=4.2.1 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(4.3.2) Requirement already satisfied: terminado>=0.8.1 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(0.8.1) Requirement already satisfied: jinja2 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(2.10) Requirement already satisfied: jupyter-core>=4.4.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(4.4.0) Requirement already satisfied: tornado>=4 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(5.0.2) Requirement already satisfied: pyzmq>=17 in
c:\users\alvaro\anaconda3\lib\site-packages (from notebook->jupyter)
(17.0.0) Requirement already satisfied: ipython in
c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-console->jupyter) (6.4.0) Requirement already satisfied:
prompt_toolkit<2.0.0,>=1.0.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-console->jupyter) (1.0.15) Requirement already satisfied:
pygments in c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-console->jupyter) (2.2.0) Requirement already satisfied:
mistune>=0.7.4 in c:\users\alvaro\anaconda3\lib\site-packages (from
nbconvert->jupyter) (0.8.3) Requirement already satisfied:
entrypoints>=0.2.2 in c:\users\alvaro\anaconda3\lib\site-packages
(from nbconvert->jupyter) (0.2.3) Requirement already satisfied:
bleach in c:\users\alvaro\anaconda3\lib\site-packages (from
nbconvert->jupyter) (2.1.3) Requirement already satisfied:
pandocfilters>=1.4.1 in c:\users\alvaro\anaconda3\lib\site-packages
(from nbconvert->jupyter) (1.4.2) Requirement already satisfied:
testpath in c:\users\alvaro\anaconda3\lib\site-packages (from
nbconvert->jupyter) (0.3.1) Requirement already satisfied:
widgetsnbextension~=3.2.0 in
c:\users\alvaro\anaconda3\lib\site-packages (from ipywidgets->jupyter)
(3.2.1) Requirement already satisfied: python-dateutil>=2.1 in
c:\users\alvaro\anaconda3\lib\site-packages (from
jupyter-client>=5.2.0->notebook->jupyter) (2.7.3) Requirement already
satisfied: jsonschema!=2.5.0,>=2.4 in
c:\users\alvaro\anaconda3\lib\site-packages (from
nbformat->notebook->jupyter) (2.6.0) Requirement already satisfied:
six in c:\users\alvaro\anaconda3\lib\site-packages (from
traitlets>=4.2.1->notebook->jupyter) (1.11.0) Requirement already
satisfied: decorator in c:\users\alvaro\anaconda3\lib\site-packages
(from traitlets>=4.2.1->notebook->jupyter) (4.3.0) Requirement already
satisfied: MarkupSafe>=0.23 in
c:\users\alvaro\anaconda3\lib\site-packages (from
jinja2->notebook->jupyter) (1.0) Requirement already satisfied:
setuptools>=18.5 in c:\users\alvaro\anaconda3\lib\site-packages (from
ipython->jupyter-console->jupyter) (39.1.0) Requirement already
satisfied: simplegeneric>0.8 in
c:\users\alvaro\anaconda3\lib\site-packages (from
ipython->jupyter-console->jupyter) (0.8.1) Requirement already
satisfied: backcall in c:\users\alvaro\anaconda3\lib\site-packages
(from ipython->jupyter-console->jupyter) (0.1.0) Requirement already
satisfied: pickleshare in c:\users\alvaro\anaconda3\lib\site-packages
(from ipython->jupyter-console->jupyter) (0.7.4) Requirement already
satisfied: colorama; sys_platform == "win32" in
c:\users\alvaro\anaconda3\lib\site-packages (from
ipython->jupyter-console->jupyter) (0.3.9) Requirement already
satisfied: jedi>=0.10 in c:\users\alvaro\anaconda3\lib\site-packages
(from ipython->jupyter-console->jupyter) (0.12.0) Requirement already
satisfied: wcwidth in c:\users\alvaro\anaconda3\lib\site-packages
(from prompt_toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter) (0.1.7)
Requirement already satisfied:
html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre in c:\users\alvaro\anaconda3\lib\site-packages (from
bleach->nbconvert->jupyter) (1.0.1) Requirement already satisfied:
parso>=0.2.0 in c:\users\alvaro\anaconda3\lib\site-packages (from
jedi>=0.10->ipython->jupyter-console->jupyter) (0.2.0) Requirement
already satisfied: webencodings in
c:\users\alvaro\anaconda3\lib\site-packages (from
html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->jupyter)
(0.5.1) distributed 1.21.8 requires msgpack, which is not installed.
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade
pip' command.
Install with PyCharm, with the libraries installation function of the interpreter settings of it. It gets also an error to install:
Install packages failed: Installing packages: error occurred.
Details...
I tried to install other libraries with success (sympy, for example), but I didn't achieve it with Jupyter and Matplotlib.
The root environment has this libraries, but I don't know if I could import from there.
How I should to proceed?
Thank you very much
This blog post explains how to install jupyter into a virtualenv (Disclaimer: I didn't come up with it myself):
http://anbasile.github.io/programming/2017/06/25/jupyter-venv/
In summary:
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
I seem to have got it probably.
TLDR: You probably installed jupyter in your base (or root in your language) environment.
I have copied over a small snippet of your messages.
Install with conda install jupyter and conda install matplotlib in the console and cd where the environment is located. The console made its process and it said that both libraries were already installed. I check it in the libraries list of Anaconda Navigator and it doesn't appear.
(base) C:\Users...>cd C:\Users\Alvaro\Anaconda3\envs\tensorflow
(base) C:\Users...\Anaconda3\envs\tensorflow>conda install matplotlib Solving environment: done
All requested packages are already installed.
(base) C:\Users\Alvaro\Anaconda3\envs\tensorflow>conda install jupyter Solving environment: done
Now I am assuming that the above packages really got installed properly.
Why I am doubtful.Solving environment: done is not the last line after a package gets installed.
If you see the first line of each of these messages they all begin with base. This indicates that the packages got installed in the base environment, not your `TensorFlow environment.
So you really won't find them in your `TensorFlow environment.
It would help if you also answer my questions in the comments below the question.

Categories

Resources