Using Gurobi on VSCode on Windows 10.
I have the following code
import gurobipy as gp
from gurobipy import GRB
Now the interesting this is that when I put this in a .py file, I get the error
No name 'GRB' in module 'gurobipy'
But doing the same thing a Jupyter notebook yields no error.
I installed gurobipy with pip as per the instructions here: https://support.gurobi.com/hc/en-us/articles/360044290292-Installing-Gurobi-for-Python
Further, I have the same version of Python (3.9.1) on both Jupyter Notebook and in the system (checked by running python --version) and pip freeze shows gurobipy installed.
I have found a fix for it.
https://medium.com/#haominnn/how-to-deal-with-python-not-finding-tensor-flow-module-under-anaconda-3aefa8ffae11
Essentially just disable pylint and replace with pep8.
The medium link is outdated for pep8, use VS Code doesn't recognize pep8 instead
Related
I have several imports in my current code:
from flask import Flask
import datetime as dt
import numpy as np
import pandas as pd
When I run this in VSCODE I am getting this error:
However, running this in jupyter notebook has no problems. When I looked online it said to use python interpreter but when I go to do that I get this error:
And another error:
Anaconda prompt says modules/packages are installed but when I run pip install in default windows terminal it says pip has no module:
Delete and reinstall Python extensions according to the same problem on github.
The second problem is related to the location of your Python interpreter. You need to choose the correct interpreter. I still recommend using one Python version in one environment. You can use other Python versions in virtual environment, so it won't lead to confusion.
Currently I am working on a project with Jupyter Notebook in which I need to run a matlab script (.m) which includes a function that provides me with data which i try to solve with a tensorflow model afterwards. I can set up an environment that runs the matlab code an gives me the data and I can set up an environment that does the tensorflow thing but my problem is I can`t do it in the same environment.
Here is the setup and the problems. I am using matlab.engine which I installed like described here: https://de.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
To run my Jupyter Notebook I first navigate to the location where my python.exe and the matlab files are lying ("C:\Users\Philipp\AppData\Local\Programs\Python\Python37-32\Scripts"). If I try to run pip install tensorflow (in Anaconda Prompt) I got a lot of different errors like the following. Conda install works but even when it is installed i can`t import it.
ImportError: No module named 'tensorflow.core' or
ERROR: Could not find a version that satisfies the requirement tensorflow or just No module named 'tensorflow'
I searched for all those problems but nothing helped me. I think this has something to do with the directory I am working in and I know it is bad but I have no idea how to change that. The error also occurs in different environments.
Have you tried running !pip install tensorflow directly in Jupyter Notebook? It's a temporary workaround, but I am having the same problems and this one helped. Remember to comment it out after installation, so you wont re-run it by accident.
I found a solution to my problem. For this I needed a Jupyter Notebook and an external .py script that I design as a Flask. I can luckily run those in different environments. I past and request the data from the server by using "get" and "post".
If someone still has another idea to do all this in one JN, I would still be happy about answers.
When I try to run
import tensorflow as tf
at pycharm , then I got the error message
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
I refer to questions like question 1 and question 2 , they are just to recommend downgrade or reinstalling.
The particularity of this problem is :
cmd image When I run import tensorflow in cmd ,it works well.
The code of this project is correct because I 'have run it on other computer .And I use CONDA to keep the environment consistent.
I have checked the interpreter of pycharm and this project and it was correct .
How can I resolve it ? I have fight with this problems for 3 days.
I had the same problem with you. I found it is the pycharm to be blamed. In tensorflow version later than 2.0.0, the main functions of tensorflow is located in tensorflow_core instead of the folder tensorflow like tensorflow 1.x. When you use cmd, python can find these packages(by some methods), but the pycharm of old version cannot. So update your pycharm or use earlier versions of tensorflow might solve your problem.
Unable to import Keras(from TensorFlow 2.0) in PyCharm. these question said that PyCharm can recognises tensorflow 2.0.0b1)
I have installed pythonnet to use clr package for a specific API, which only works with clr in python. Although in my python script (using command or regular .py files) it works without any issues, in jupyter notebook, import clr gives this error, ModuleNotFoundError: No module named 'clr'. Any idea how to address this issue?
Here is simple suggestion: compare sys.path in both cases and see the differences. Your ipython kernel in jupyter is probably searching in different directories than in normal python process.
since you are intended to use clr in jupyter, in jupyter cell, you could also
!pip install pythonnet for the first time and every later time if the vm is frequently nuked
I am new to Python and Jupyter notebook. I am using Windows 10.
I already installed Anaconda3 and tried to import cplex in Jupyter notebook environment.
But I only got the below error:
ModuleNotFoundError: No Module named 'cplex'
I did find some resolutions for that, but neither of them fixed the problem.
I think I have to set path or install something for using the CPLEX in Jupyetr notebook, but I cannot find how I do that.
You should have a look at https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Python_setup.html
You could use the Docplex api: http://ibmdecisionoptimization.github.io/docplex-doc/mp/getting_started_python.html
You could even start without installing cplex on your machine. (But call cplex in the cloud https://developer.ibm.com/docloud/try-docloud-free/)
And you could also use docplex in Watson Studio: https://dataplatform.cloud.ibm.com/docs/content/DO/DOcplex.html